private static AdjacencyGraph <NamedVertex, NamedEdge> Convert(AdjacencyGraph <string, Edge <string> > g)
        {
            AdjacencyGraph <NamedVertex, NamedEdge> cg =
                new AdjacencyGraph <NamedVertex, NamedEdge>();

            System.Collections.Generic.Dictionary <string, NamedVertex> vertices = new System.Collections.Generic.Dictionary <string, NamedVertex>(g.VertexCount);
            foreach (string v in g.Vertices)
            {
                NamedVertex iv = new NamedVertex(v);
                iv.Name = v;
                vertices.Add(v, iv);
                cg.AddVertex(iv);
            }
            int count = 0;

            foreach (Edge <string> e in g.Edges)
            {
                NamedEdge edge = new NamedEdge(
                    count.ToString(),
                    vertices[e.Source],
                    vertices[e.Target]
                    );
                edge.Name = edge.Source.Name + "->" + edge.Target.Name;
                cg.AddEdge(edge);
                count++;
            }
            return(cg);
        }
Example #2
0
        public bool Test(IEdge e)
        {
            NamedEdge ne = e as NamedEdge;

            if (ne == null)
            {
                return(false);
            }
            return(ne.Name == name);
        }
        public XmlSerializationTest()
        {
            m_Graph = new AdjacencyGraph(
                new NamedVertexProvider(),
                new NamedEdgeProvider(),
                true
                );

            u = (NamedVertex)Graph.AddVertex(); u.Name = "u";
            v = (NamedVertex)Graph.AddVertex(); v.Name = "v";
            w = (NamedVertex)Graph.AddVertex(); w.Name = "w";

            uv = (NamedEdge)Graph.AddEdge(u,v); uv.Name = "uv";
            uw = (NamedEdge)Graph.AddEdge(u,w); uw.Name = "uw";
        }