Marking Nodes on a Digraph

119 views Asked by At

I have a digraph problem where I need to mark each node and print the nodes as marked and unmarked with regarding the edges in the given input and accept or reject if they are both marked in their respective start and end state in java. I have figured out how to parse each value into its individual entity, but I cannot figure out how to traverse the graph using the designated input that has gotten parsed in the form it is in regarding parentheses. Here is an example:

input : (1,2,3,4,5),((1,2),(1,3),(2,3),(2,4),(3,2),(3,5),(4,3),(5,2)),1,5
nodes are: (1,2,3,4,5)
Edges are : (1,2),(1,3),(2,3),(2,4),(3,2),(3,5),(4,3),(5,2)
Start state: 1
End state: 5

How would one go about traversing these nodes and check the edges if they are marked or unmarked? Stack, etc?

I just don't understand how to show that the node has gone to each node and marked it given these parentheses.

0

There are 0 answers