Change in behavior of scala-graph 2.0 for multiple edges between same two nodes

41 views
Skip to first unread message

Allan Brighton

unread,
Feb 21, 2024, 7:20:24 AM2/21/24
to scala-graph
I updated to scala-graph 2.0 and noticed a change when two nodes have multiple directed edges with only different labels. In scala-graph 1.x both edges were shown (when converting to Dot), but in 2.0 only one of the edges is shown. Is this expected behavior?

The models I am using look like this:

```
  // Type of an edge label
  private case class EdgeLabel(labels: List[String], edgeType: EdgeType, missing: Option[MissingType] = None) {
    lazy val label: String = labels.sorted.mkString("\\n")
  }

  // Holds both components of an edge
  private case class ComponentPair(from: String, to: String)

  // Describes an Edge from one component to another
  private case class EdgeModel(components: ComponentPair, label: EdgeLabel)

  // Labeled directed edges
  private case class MyLDiEdge(model: EdgeModel)
      extends AbstractDiEdge(source = model.components.from, target = model.components.to)
  private object MyGraph extends TypedGraphFactory[String, MyLDiEdge]

// ...
    val allEdgeModels: List[EdgeModel] = ...
    val g = MyGraph.from(
      allEdgeModels.map(MyLDiEdge)
    )

    // Convert to dot
    val dot = g.toDot(
      dotRoot = root,
      edgeTransformer = edgeTransformer,
      cNodeTransformer = Some(nodeTransformer)
    )
```

Allan Brighton

unread,
Feb 21, 2024, 9:32:23 AM2/21/24
to scala-graph
Here is a small example that demonstrates the problem: There should be two edges from "A" to "B", but only one is shown.

(See attached Test.scala)

Test.scala

empen...@gmail.com

unread,
Feb 24, 2024, 11:27:21 AM2/24/24
to scala-graph
Did you also try to mix in MultiEdge? The easiest way to define a multigraph is also described in Core User Guide: Plan Your Graph.
Does this help?

Allan Brighton

unread,
Feb 24, 2024, 3:28:47 PM2/24/24
to scala-graph

Yes, that was it (MultiEdge). 

Thanks,
Allan
Reply all
Reply to author
Forward
0 new messages