Skip to content

Commit 2cd9448

Browse files
committed
Fixing the toStrings
1 parent ba58c6f commit 2cd9448

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ These are typically very straightforward to create. The decorator semirings list
108108

109109
convertEdgeToLabelFunc:(Node,Node,ArcLabel)=>Label
110110

111-
These methods also allow for an optional extraNodes Seq. This Seq can contain both extra nodes and any nodes that already exist in the edges, and can control the ordering of the algorithm's output.
111+
These methods also allow for an optional nodes Seq. This Seq can contain both extra nodes and any nodes that already exist in the edges, and can control the ordering of the algorithm's output.
112112

113113
FloydWarshall, Dijkstra, and Brandes each also include a method that takes an IndexedDigraph implementation, mutable for FloydWarshall. If you use this method then you are responsible for creating the labelDigraph correctly. I included it primarily for computational efficiency, and for a future lazy evaluator for Dijkstra's method.
114114

src/main/scala/net/walend/graph/AdjacencyLabelDigraph.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class AdjacencyLabelDigraph[Node,Label](outNodes:Vector[Node], //provides the ma
126126
}
127127

128128
override def toString:String = {
129-
s"$inNodes $edges"
129+
s"${this.getClass.getSimpleName}(edges = $edges,nodes = $outNodes,noEdgeExistsValue = $noEdgeExistsLabel)"
130130
}
131131
}
132132

@@ -136,10 +136,10 @@ class AdjacencyLabelDigraph[Node,Label](outNodes:Vector[Node], //provides the ma
136136
object AdjacencyLabelDigraph{
137137

138138
def apply[Node,Label](edges:GenTraversable[(Node,Node,Label)] = Seq.empty,
139-
extraNodes:GenSeq[Node] = Seq.empty,
139+
nodes:GenSeq[Node] = Seq.empty,
140140
noEdgeExistsValue:Label = null) = {
141141

142-
val nodeValues:Vector[Node] = (extraNodes ++ edges.map(_._1) ++ edges.map(_._2)).distinct.to[Vector]
142+
val nodeValues:Vector[Node] = (nodes ++ edges.map(_._1) ++ edges.map(_._2)).distinct.to[Vector]
143143

144144
val successorMap:GenMap[Node,GenTraversable[(Node,Node,Label)]] = edges.groupBy(_._1)
145145
val predecessorMap:GenMap[Node,GenTraversable[(Node,Node,Label)]] = edges.groupBy(_._2)

src/main/scala/net/walend/graph/MatrixLabelDigraph.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ class MatrixLabelDigraph[Node,Label](outNodes:Vector[Node], //provides the maste
6161
case _ => false
6262
}
6363
}
64-
6564
}
6665

6766
/**
@@ -142,6 +141,9 @@ class MatrixLabelDigraph[Node,Label](outNodes:Vector[Node], //provides the maste
142141
*/
143142
override def label(i: Int, j: Int): Label = edgeMatrix(i)(j)
144143

144+
override def toString:String = {
145+
s"${this.getClass.getSimpleName}(edges = $edges,nodes = $outNodes,noEdgeExistsValue = $noEdgeExistsLabel)"
146+
}
145147
}
146148

147149
object MatrixLabelDigraph{
@@ -150,10 +152,10 @@ object MatrixLabelDigraph{
150152
* O(n ln(n) + en)
151153
*/
152154
def apply[Node,Label](edges:GenTraversable[(Node,Node,Label)] = Seq.empty,
153-
extraNodes:GenSeq[Node] = Seq.empty,
155+
nodes:GenSeq[Node] = Seq.empty,
154156
noEdgeExistsValue:Label = null) = {
155157

156-
val nodeValues:Vector[Node] = (extraNodes ++ edges.map(_._1) ++ edges.map(_._2)).distinct.to[Vector]
158+
val nodeValues:Vector[Node] = (nodes ++ edges.map(_._1) ++ edges.map(_._2)).distinct.to[Vector]
157159

158160
val size = nodeValues.size
159161

0 commit comments

Comments
 (0)