VertexEdgeDictionary names = new VertexEdgeDictionary();
...
// this will fail names.Values implements IEnumerable.
IEdgeEnumerable c = names.Values;
// wrapping the values
IEdgeEnumrable c = new EdgeEnumerable(names.Values);
VertexStringDictionary names = new VertexStringDictionary();
// adding names
...
// this will fail names.Keys implements IEnumerable.
IVertexEnumerable c = names.Keys;
// wrapping the keys
IVertexEnumrable c = new VertexEnumerable(names.Keys);
Vertex v; // vertex
foreach(Edge e in v.InEdges)
{
Console.WriteLine("{0} -> {1}",
e.Source.GetHashCode(),
e.Target.GetHashCode()
);
}
Copyright (c) 2004 Jonathan de Halleux
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from
the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented;
you must not claim that you wrote the original software.
If you use this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
QuickGraph Library HomePage: http://www.mbunit.com
Author: Jonathan de Halleux
ep(e) && vp(e.Source) && vp(e.Target)
ep(e) && vp(e.Source)
ep(e) && vp(e.Target)
using System.Xml;
using QuickGraph.Serialization;
...
// create human readable xml writer
XmlTextWriter writer = new XmlTextWriter(Console.Out);
writer.Formatting = Formatting.Indented;
// the graph to serialize
ISerializableVertexAndEdgeListGraph g = ...;
// create serializer
GraphMLGraphSerializer ser = new GraphMLGraphSerializer();
// serialize graph
ser.Serialize(writer,g);
// getting xml writer
XmlTextWriter writer = new XmlTextWriter(Console.Out);
writer.Formatting = Formatting.Indented;
// gettin graph
AdjacencyGraph g = ...;
GraphSerializer ser = new GraphMlSerializer();
// serialize to GraphML
ser.Serialize(writer,g);
AdjacencyGraph g = new AdjacencyGraph(
new NamedVertexProvider(),
new NamedEdgeProvider(),
true
);
NamedEdge u = (NamedVertex)Graph.AddVertex(); u.Name = "u";
NamedEdge v = (NamedVertex)Graph.AddVertex(); v.Name = "v";
NamedEdge w = (NamedVertex)Graph.AddVertex(); w.Name = "w";
NamedEdge uv = (NamedEdge)Graph.AddEdge(u,v); uv.Name = "uv";
NamedEdge uw = (NamedEdge)Graph.AddEdge(u,w); uw.Name = "uw";
StringWriter sw = new StringWriter();
XmlTextWriter writer = new XmlTextWriter(sw);
writer.Formatting = Formatting.Indented;
GraphSerializer ser = new GraphSerializer(Graph);
ser.WriteXml(writer);
Console.WriteLine(sw.ToString());
StringReader sr = new StringReader(sw.ToString());
XmlTextReader reader = new XmlTextReader(sr);
ser.ReadXml(reader);
sw = new StringWriter();
writer = new XmlTextWriter(sw);
writer.Formatting = Formatting.Indented;
ser.WriteXml(writer);
Console.WriteLine(sw.ToString());