public edge <T> getEdgeByName(string edge) { vertex <T> source = (vertex <T>)_vertex.Where(e => e.Name == edge[0].ToString()).ToList().ElementAt(0); vertex <T> Destiantion = (vertex <T>)_vertex.Where(e => e.Name == edge[1].ToString()).ToList().ElementAt(0); return(source.getEdge(Destiantion)); }
static void Main(string[] args) { /* * Graph<string> g1 = new Graph<string>("a,b,c,d,e,f,g", "ab,cd,ef,aa,eg", "1,2,3,4,5,6,7", "a"); * Console.WriteLine(g1.getEdgeByName("ef").weight); * * vertex<double> a = new vertex<double>("a"); * vertex<double> b = new vertex<double>("b"); * vertex<double> c = new vertex<double>("c"); * vertex<double> d = new vertex<double>("d"); * vertex<double> e = new vertex<double>("e"); * a.addEdge(b); * a.addEdge(c); * b.addEdge(c); * b.addEdge(d); * d.addEdge(c); * d.addEdge(e); * e.addEdge(c); * Graph<double> graph1 = new Graph<double>(new List<vertex<double>> { a, b, c, d, e }); * vertex<double> f = new vertex<double>("f"); * graph1.addVertix(f); * graph1.addEdge(e, f); * Console.WriteLine(graph1.getVertex(a).Name); * graph1.move(e); * Console.WriteLine(graph1.currentVertex.Name); * graph1.removeEdge(c, d); * Console.Read(); */ vertex <double> a = new vertex <double>("a"); vertex <double> b = new vertex <double>("b"); a.addEdge(b); Console.WriteLine(a.getEdge(b).weight.ToString()); edge <double> DtoS = new edge <double>(a, b); Console.WriteLine(DtoS.destinationVertex.Name); Console.WriteLine(DtoS.sourceVertex.Name); Console.WriteLine(DtoS.weight.ToString()); Console.Read(); }