I\'m concerned that this might be working on an NP-Complete problem. I\'m hoping someone can give me an answer as to whether it is or not. And I\'m looking for more of an an
If all you need is to determine if 2 nodes are connected you can use sets instead, which is faster than graph algorithms.
At first your nodes will be each in its set,
o o1 o o o o o o2
\ / \ / \ / \ /
o o o o o o o o
\ / \ /
o o o o o o o o
\ /
o o1 o o o o o o2
As the algorithm progresses and merges the sets, it relatively halves the input.
In the example above I was looking to see if there was a path between o1 and o2. I found this path only at the end after merging all edges. Some graphs may have separate components (disconnected) which entails that you will not be able to have one set at the end. In such a case you can use this algorithm to test for connectedness and even count the number of components in a graph. The number of components is the number of sets you are able to get when the algorithm finishes.
A possible graph (for the tree above):
o-o1-o-o-o2
| |
o o
|
o
not NP-complete, solved with a well-known solution - Dijkstra's Algorithm
To me it seems like you are on to a solution, but it's possible I misunderstood the problem. If you do like you say, and give the closed edges 1 as weight, you can just apply Dijkstra's algorithm, http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm. This should solve your problem in O(E*lg(V))
Dijkstra's is overkill!! Just use breadth first search from A to search for the node you want to reach. If you can't find it, it's not connected. Complexity is O(nm) for each search, which is less then Dijkstra.
Somewhat related is the max-flow/min-cut problem. Look it up, it might be relevant to your problem.
You don't need Dijkstra's algorithm for this problem, as it uses a Heap which isn't needed and introduces a factor of log(N) to your complexity. This is just breadth first search - don't include the closed edges as edges.