I've been looking for this one in a while but coudn't find anything.
I am trying to deserialize graph from GraphML using Quickgraph in C#. Here's the class I use to represent Vertex and Edge
[Serializable]
public class Room
{
public Room(int id, double x, double y)
{
this.Ids = id;
this.x = x;
this.y = y;
}
[XmlAttribute("id")]
public int Ids { get; set; }
[XmlAttribute]
public double x { get; set; }
[XmlAttribute]
public double y { get; set; }
}
[Serializable]
public class HouseEdge<TVertex> : Edge<TVertex>
{
public string Name { get; set; }
public HouseEdge(TVertex source, TVertex target)
: base(source, target)
{
}
}
And I am trying to deserialize the code using method DeserializeFromGraphML:
XmlReader xreader = getXMLReader("//house.xml");
IdentifiableVertexFactory<Room> ivf = new IdentifiableVertexFactory<Room>(makeTest);
IdentifiableEdgeFactory<Room, HouseEdge<Room>> ief = new IdentifiableEdgeFactory<Room, HouseEdge<Room>>(makeTest2);
graph.DeserializeFromGraphML<Room, HouseEdge<Room>, AdjacencyGraph<Room, HouseEdge<Room>>>(xreader, ivf, ief);
xreader.Close();
And here's the code for makeTest and makeTest2:
private Room makeTest(string cos)
{
MessageBox.Show(cos);
return new Room(11, 12.0, 13.0);
}
private HouseEdge<Room> makeTest2(Room one, Room two, string cos)
{
MessageBox.Show(cos);
return new HouseEdge<Room>(one, two);
}
So - in my XML file I got 2 vertices - (0,0,0) and (1,1,1) and edge between them. When I deserialize them edge is just fine but vertices goes (0,12,0) and (1,12,1). There has to be something that I'm missing (twelve comes from makeTest method) but cos
variable only has number zero and one just as position of vertex in the "Vertices" of graph (that's what I'm showing in MessageBox)
I know it can be complex at first glance but maybe it's really simple? Am I missing something?
Thanks in advance!