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(); }
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(); }
public void addEdge(vertex <T> sourceVertex, vertex <T> DestinationVertex, T weight = default(T)) {//connect two vertices togther throught an edge sourceVertex.addEdge(DestinationVertex, weight); }
public void addEdge(vertex <T> TargetVertex, T weight = default(T)) {//connects the current vertex to another vertex _CurrentVertix.addEdge(TargetVertex, weight); }