/// <summary> /// returns sub graph neighbors vertices in super graph /// </summary> /// <param name="super"></param> /// <param name="sub"></param> /// <returns></returns> public static List<Vertice> GetVerticesNeighborhood(Graph super, Graph sub,Vertice subVertice) { List<Vertice> nhood = new List<Vertice>(); foreach (Edge e in super.Edges) if (subVertice.index == e.v1 && !sub.Contains(e)) { nhood.Add(new Vertice(e.v2)); } else if (subVertice.index == e.v2 && !sub.Contains(e)) { nhood.Add(new Vertice(e.v1)); } return nhood; }
/// <summary> /// returns sub graph neighbors edges in super graph /// </summary> /// <param name="super"></param> /// <param name="sub"></param> /// <returns></returns> public static List<Edge> GetEdgesNeighborhood(Graph super, Graph sub) { List<Edge> nhood = new List<Edge>(); foreach (Vertice v in sub.Vertices) foreach (Edge e in super.Edges) if (e.v1 == v.index || e.v2 == v.index && !sub.Contains(e)) nhood.Add(e); return nhood; }
private static int GetCollaterialSign(Graph graph, Edge e) { if (graph.Contains(e)) return 1; return -1; }
private static int GetTentativeDistance(Graph graph, Vertice v1, Vertice v2) { if (v1 == v2) return 0; if (graph.Contains(new Edge(v1.index, v2.index))) return 1; return int.MaxValue; }
//Collaterial and Pair graphs private static Graph GetCollaterialGraph(Graph graph, Edge e) { if (!graph.Contains(e)) return graph; Graph collaterial = new Graph(); collaterial.Vertices = graph.Vertices; foreach (Edge current in graph.Edges) { if (current != e) collaterial.Edges.Add(current); } return collaterial; }