static int FindShortestPath(ConAndDisGraph graph, int start, int end) { // check in discon first as it can be faster ? // check in connected via bfs, if not found in connected it is -1 int distance = 0; Queue <Node> queue = new Queue <Node>(); queue.Enqueue(graph.connectedNodes); while (queue.Count > 0) { Node node = queue.Dequeue(); foreach (Node n in node.neighbors) { distance = distance + 6; if (n.data == end) { return(distance); } else { queue.Enqueue(n); } } } // could not find end node return(-1); }
static ConAndDisGraph CreateGraph(int n, int e, int[][] edges, int s) { ConAndDisGraph graph = new ConAndDisGraph(); for (int i = 0; i < edges.Length; i++) { graph.connectedNodes.data = edges[i][0]; // Find node to be inserted, if present add the neighbor to it } return(null); }