laemtao
laemtao

Reputation: 147

Check to see if list of nodes is connected within graph

I have a list of nodes from a graph, G:

43, 47, 48, 49, 51, 55, 65, 66

I want to check if they are connected as such that I can produce a connected subgraph from these nodes from the graph, G.

But exactly as such where I can start at a terminal node (such as 47, 43, 55 ) and without taking my pencil off the paper, trace until I get to a specified node of choice.

Please see the attached picture for my graph and the path that would exist from node 47:49, 51, 65:66 leaving out 43 and 55 which would otherwise end the chain prematurely

  1. What is this called in graph theory? (So I can do some research on it)

  2. What is the best way to implement this?

Thanks!

Upvotes: 0

Views: 166

Answers (1)

Dinesh
Dinesh

Reputation: 2204

I think you can use Depth First Search to find if the nodes are connected.

Upvotes: 1

Related Questions