Open fubar-coder opened 6 years ago
Form unknown CodePlex user on Tuesday, 01 February 2011 07:40:26
Hi, Alexandre -- I am not sure what your error is, but I solved some Namespace difficulties when reading such files with Linq-to-XML. Here is sample code that works over yEd graphml files
var graph = new AdjacencyGraph<string, Edge
var file = @". . . your file path here . . ."; var theDoc = XDocument.Load(file);
(from node in theDoc.Descendants() where node.Name.LocalName == "node" select graph.AddVertex(node.Attribute("id").Value)).Run();
var edges = (from edge in theDoc.Descendants()
where edge.Name.LocalName == "edge"
select new Edge
edges.Select(graph.AddEdge).Run();
var edgeCost = new Dictionary<Edge
var dijkstra = new DijkstraShortestPathAlgorithm<string, Edge
var predObsvr = new QuickGraph.Algorithms.Observers
.VertexPredecessorRecorderObserver<string, Edge
var distObsvr = new VertexDistanceRecorderObserver<string, Edge
From unknown CodePlex user on Tuesday, 27 October 2009 06:53:41
Hi,
First of all I'd like to say that QuickGraph is a impressive piece of work. Congratuations! I'm looking for a way to read graphml files generated by yEd, a free graph editor. www.yworks.com/products/yed/ I can't easily figure out how to customize the Deserializer to read such Nodes, I get a not very meaningful error when trying to deserialize a graph (see xml below) with this code
var g = new AdjacencyGraph<string, Edge>();
using (var xreader = XmlReader.Create("z:/test.graphml"))
{
g.DeserializeFromGraphML(xreader,
id => id,
(source, target, id) => new Edge(source, target)
);
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
What would be the minimum steps to read succesfully the graph, without data attached, and possibly with the data nodes as well? Thanks for your help! Alexandre