Saving Graphs

Topics: graph
Oct 15, 2007 at 2:34 PM
Is there any way to save graphs created by quickgraph and open the graph at a later time?
Oct 15, 2007 at 6:53 PM
The GraphMLSerializer will serialize a graph to the GraphML format. Are you looking for .Net serialization support?
Nov 9, 2007 at 4:33 PM
Edited Nov 20, 2007 at 8:33 AM
I've tried using the GraphMLSerializer but I'm currently having problems with the deserialization process. I'm using the BidirectionalGraph.

Here's the graph initialization.
// single line
{ { BidirectionalGraph<IdentifiableVertex, IdentifiableEdge<IdentifiableVertex>> distributionGraph = new idirectionalGraph<IdentifiableVertex, IdentifiableEdge<IdentifiableVertex>>(); } }

Here's the serialization code
{ {
GraphMLSerializer<IdentifiableVertex, IdentifiableEdge<IdentifiableVertex>> s = new GraphMLSerializer<IdentifiableVertex, IdentifiableEdge<IdentifiableVertex>>();

XmlTextWriter x = new XmlTextWriter( GRAPH_FILE, Encoding.UTF8 );
s.Serialize( x, distributionGraph );
} }

Here's the deserialization code.
{ {
GraphMLSerializer<IdentifiableVertex, IdentifiableEdge<IdentifiableVertex>> s = new GraphMLSerializer<IdentifiableVertex, IdentifiableEdge<IdentifiableVertex>>();

IdentifiableVertexFactory vFact = new IdentifiableVertexFactory();
IdentifiableEdgeFactory<IdentifiableVertex> eFact = new IdentifiableEdgeFactory<IdentifiableVertex>();

XmlTextReader r = new XmlTextReader( GRAPH_FILE );
s.Deserialize( r, distributionGraph, vFact, eFact );
} }

The error message I'm getting is "Cannot find vertex 1" or "There is no root element"
Dec 13, 2007 at 4:01 PM
I'll take a look.
Jan 11, 2008 at 12:18 AM
Edited Jan 11, 2008 at 12:19 AM
Any updates on this case? Looks like serialization is not generating any output (definately in my case). Thx.
Jan 31, 2008 at 4:50 AM
Please send a full unit test case that I can try out. thanks.
Oct 28, 2008 at 6:06 AM
Hi Jonathan,

I was happy to find this package because it supports one of my main requirements: serialization to GraphML and back. Unfortunately I haven't been able to get even your serialization round-trip example to work. I made a copy of the QuickGraph.Tests folder and added it as a project to my solution. I ripped out all files from the QuickGraph.Tests project that did not compile because of references to System.Threading which I don't seem to have in my .NET installation. After this I was able to build the executable. When run it generated a html file which had 476 tests but one failure: the serialization test !! I also created the following snippet:

      static void Main(string[] args)
         GraphMLSerializerTest serializerTest = new GraphMLSerializerTest();


but this fails with the same error: an AccessViolation exception at GraphMLSerializer.cs line 516.

I am using VS2008 installed on an x64 Vista machine.

Has anybody else had this same problem ?


Nov 2, 2008 at 7:32 AM
My serializer might have a bug (I use dynamic code generation for performance). Could you send me the type of the edge, vertex that you are trying to serialize.

I'll take a look at the serialization test.
Nov 2, 2008 at 2:07 PM
A snippet to repro would be appreciated.
Nov 2, 2008 at 8:57 PM
I've checked in a fix.
Nov 2, 2008 at 8:57 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.