How to parse a diagram

I’m trying to parse a diagram that based on OR/AND gates.
so, when nodes connected to AND gate they will be serial in the path. But if the gate is OR this means different parallel paths.

Did you have a specific question?

Yes, Thank you Walter,
The question is:
My part of code for parsing and creating paths like this:


myDiagram.model = model;
var serials = new go.List(go.node);
var Path = new go.List(go.node);

	n=myDiagram.findNodeForKey("Actuator 1");
	Path.add(n);
	lastNode=Path.o[Path.length-1]
	//console.log(Path.o[Path.length-1].data.name);
//	while (n !== null) {    	
parents = new go.List(go.node);

while (lastNode !== null) {
	if(lastNode.data.category !=="actuator") Path.add(lastNode);

			 	  if ( lastNode.data.category  === "hub" ){
						gate=lastNode.findNodesOutOf();  gateCat=gate.value.data.category;
						switch(gateCat) {
							case "or":

									 var it = lastNode.findNodesInto();
									 while (it.next()) {

										  var parent = it.value;
								 		   console.log("parent" +"  "+parent.data.name+" "+ parent.findTreeLevel())


										  Path.add(parent);	
								 	      break; 
										  parents.add(parent);

//continue;
}

							case "and":			
						//		console.log("---  "+ gate.value.data.name);
							
							 var itn = lastNode.findNodesInto();
							 while (itn.next()){
							 	var serialNode = itn.value;
						//		console.log(serialNode.data.name);

							//	Path.push(serialNode);
											
											var itl = serialNode.findLinksInto();
												while (itl.next()) {
																
																var link = itl.value;
		 													//	console.log(link.fromNode.data.name);
													 			Path.push(link.fromNode);

													 			var neighbor = link.getOtherNode(serialNode);	
													 					while(neighbor !==null){
													//					console.log(neighbor.data.name);
													 			 		Path.push(neighbor);
													 					neighbor=neighbor.findTreeParentNode();
													 										}	
																	}
												} // nodesOfHub
											 	break;
											}	//switch(gateCat) 
						}	// if hub			
						lastNode = Path.o[Path.length-1].findTreeParentNode();	
				myDiagram.highlightCollection(parents);

}

// Show Values in List
var it = Path.iterator;
while (it.next()) {
var item = it.value;
console.log(Path.indexOf(item)+"—> "+item.data.name);

         setOutputLinks(item, "yellow");}

The Result logs:
0—> RR_Valve
1—> transition 1
2—> OR 2
3—> ABS OR TCS Hub
4—> ABS_Control_Cmd
5—> ABS_Control_drv twice
7—> AND 5
8—> ABS Hub
9—> OR 1
10—> R_Diff OR F_Diff OR RD Hub
11—> R_Speed_Diff
12—> R_Speed_Diff_Est
13—> AND 1
14—> RR&RL Hub
15—> RR_Speed
16—> RR_Speed_Est
17—> RR_Speed_sensor
18—> TCS_Control_drv twice
20—> AND 4
21—> TCS Hub
22—> Accel_Padel_Pos
23—> Accel_Padel_Drv
24—> Acceleration_Padel


I am trying to get:

Path1:
0—> RR_Valve
1—> transition 1
2—> OR 2
3—> ABS OR TCS Hub
4—> ABS_Control_Cmd
5—> ABS_Control_drv
7—> AND 5
8—> ABS Hub
9—> Brake_Padel_Pos
10—> Brake_Padel_Drv
11—> Brake_Padel
12—> OR 1
13—> R_Diff OR F_Diff OR RD Hub
14—> R_Speed_Diff
15—> R_Speed_Diff_Est
16—> AND 1
17—> RR&RL Hub
15—> RR_Speed
16—> RR_Speed_Est
17—> RR_Speed_sensor
18—> RL_Speed
20—> RL_Speed_Est
21—> RL_Speed_sensor

Path2:
0—> RR_Valve
1—> transition 1
2—> OR 2
3—> ABS OR TCS Hub
4—> TCS_Control_Cmd
5—> TCS_Control_drv
6—> AND 4
7—> TCS Hub
8—> Accel_Padel_Pos
9—> Accel_Padel_Drv
10—> Accel_Padel
11—> F_Speed_Diff
12—> F_Speed_Diff_Est
13—> AND 2
14—> FR&FL Hub
15—> FR_Speed
16—> FR_Speed_Est
17—> FR_Speed_sensor
18—> FL_Speed
19—> RL_Speed_Est
20—> RL_Speed_sensor

and so on for every possible path.

Thank you for patience.

Have you seen Graph Distances and Paths ? Take a look at the collectAllPaths function.

Note: that is not the solution to your exact problem, for which I do not understand the details. But it does demonstrate how to produce all possible paths between two nodes.