public override void AddEdges(Edge e1, Edge e2) { AdjacentGraph G = this; G += e1; G += e2; }
public override void AddNodes(Node n1, Node n2) { AdjacentGraph G = this; G += n1; G += n2; }
public override void AddEdges(params Edge[] e) { AdjacentGraph G = this; for (int i = 0; i < e.Length; i++) { G += e[i]; } }
public override void AddEdges(Edge e1, Edge e2, Edge e3, Edge e4) { AdjacentGraph G = this; G += e1; G += e2; G += e3; G += e4; }
public override void AddNodes(params Node[] n) { AdjacentGraph G = this; for (int i = 0; i < n.Length; i++) { G += n[i]; } }
public override void AddNodes(Node n1, Node n2, Node n3, Node n4) { AdjacentGraph G = this; G += n1; G += n2; G += n3; G += n4; }
public static AdjacentGraph operator +(AdjacentGraph G1, AdjacentGraph G2) { AdjacentGraph GF = new AdjacentGraph(G1); foreach (var v in G2.adjacent) { if (GF.adjacent.ContainsKey(v.Key) != true) { GF.adjacent[v.Key] = new Dictionary <string, int>(); } foreach (var r in v.Value) { GF.adjacent[v.Key][r.Key] = G2.adjacent[v.Key][r.Key]; } } return(GF); }
public AdjacentGraph CutEdge(Edge ed) { AdjacentGraph G = this; G -= ed; if ((G.adjacent[ed.finish.name].Count != 0) && (G.adjacent[ed.start.name].Count != 0)) { return(G); } bool b2 = true; bool b1 = true; if (G.adjacent[ed.finish.name].Count() != 0) { b2 = false; } else if (G.adjacent[ed.start.name].Count() != 0) { b1 = false; } foreach (var v in G.adjacent.Keys) { if (G.adjacent[v].ContainsKey(ed.finish.name) == true) { b2 = false; } if (G.adjacent[v].ContainsKey(ed.start.name) == true) { b1 = false; } } if (b2 == true) { G -= ed.finish; } if (b1 == true) { G -= ed.start; } return(G); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj.GetType() != this.GetType()) { return(false); } AdjacentGraph G = obj as AdjacentGraph; if (G.adjacent.Count != this.adjacent.Count) { return(false); } foreach (var node1 in G.adjacent) { if (this.adjacent.ContainsKey(node1.Key) == false) { return(false); } if (node1.Value.Count() != this.adjacent[node1.Key].Count()) { return(false); } foreach (var no in node1.Value) { if (this.adjacent[node1.Key].ContainsKey(no.Key) == false) { return(false); } if (this.adjacent[node1.Key][no.Key] != G.adjacent[node1.Key][no.Key]) { return(false); } } } return(true); }
public AdjacentGraph(AdjacentGraph G) : this(G.adjacent) { }