@@ -109,11 +109,14 @@ class AllPathsFirstSteps[Node,CoreLabel,Key](coreSupport:SemiringSupport[CoreLab
109
109
def leastPathsOfInnerNodes (fromInner: Option [leastPathDigraph.InnerNodeType ],
110
110
toInner: Option [leastPathDigraph.InnerNodeType ]): Seq [Path ] = {
111
111
val fromToOption : Option [(leastPathDigraph.InnerNodeType , leastPathDigraph.InnerNodeType )] = for (f <- fromInner; t <- toInner) yield (f, t)
112
+ // If fromToOption is None, then one node or the other isn't in the graph. Return no Path
112
113
fromToOption.fold(Seq .empty[Path ])(fromTo => {
113
114
val label : Label = leastPathDigraph.label(fromTo._1, fromTo._2)
115
+ // If label is None, then there's no path from one node to the other. Return no Path
114
116
label.fold(Seq .empty[Path ])(firstSteps => {
115
117
if (firstSteps.choices == Set .empty) Seq (Seq (fromTo._2)) // No further steps. from should be to and the label should be I
116
118
else {
119
+ // Follow each choice and prepend the node this starts from
117
120
for (choice <- firstSteps.choices.to[Seq ]) yield {
118
121
val tails : Seq [Path ] = leastPathsOfInnerNodes(leastPathDigraph.innerNode(choice), toInner)
119
122
for (tail <- tails) yield {
@@ -128,7 +131,6 @@ class AllPathsFirstSteps[Node,CoreLabel,Key](coreSupport:SemiringSupport[CoreLab
128
131
val fromInner = leastPathDigraph.innerNode(from)
129
132
val toInner = leastPathDigraph.innerNode(to)
130
133
131
- // prepend fromInner to all?
132
134
leastPathsOfInnerNodes(fromInner,toInner)
133
135
}
134
136
/**
@@ -142,6 +144,8 @@ class AllPathsFirstSteps[Node,CoreLabel,Key](coreSupport:SemiringSupport[CoreLab
142
144
def recurse (innerFrom: labelGraph.InnerNodeType ,innerTo: labelGraph.InnerNodeType ): Set [(labelGraph.InnerNodeType ,labelGraph.InnerNodeType ,Label )] = {
143
145
val label : Label = labelGraph.label(innerFrom,innerTo)
144
146
147
+ // if the label is None then return an empty set
148
+ // otherwise, follow the choices
145
149
label.fold(Set .empty[(labelGraph.InnerNodeType ,labelGraph.InnerNodeType ,Label )])(firstSteps => {
146
150
val innerChoices = firstSteps.choices.map(choice => labelGraph.innerNode(choice).get)
147
151
val closeEdges : Set [(labelGraph.InnerNodeType ,labelGraph.InnerNodeType ,Label )] = innerChoices.map((innerFrom,_,label))
0 commit comments