Having trouble with Labelled Edge implicits

41 views
Skip to first unread message

Tim Barclay

unread,
May 24, 2018, 9:12:27 AM5/24/18
to scala-graph
I'm having some trouble understanding the section about Labelled Edges at http://www.scala-graph.org/guides/core-initializing.html. I have the following code:

import scalax.collection.Graph
import scalax.collection.edge.Implicits._
import scalax.collection.edge.LBase.LEdgeImplicits

sealed abstract class Relationship(name: String)
case object A extends Relationship("A")
object RelImplicits extends LEdgeImplicits[Relationship]
import RelImplicits._

case class NodeType(id: Int)
val a
= NodeType(1)
val b
= NodeType(2)

val g
= Graph((a ~+#> b)(A))

g
.edges.headOption map(_.name) // error: value name is not a member of g.EdgeT
g
.edges.headOption map(_.label.name) // error:value nameisnot a member ofscalax.collection.edge.LkDiEdge[NodeT]#L1

What's causing those last two lines not to compile? As far as I can see I'm doing effectively the same thing as on the core-initializing page.

Peter Empen

unread,
May 25, 2018, 5:16:10 AM5/25/18
to scala-graph
Hi Tim,

I guess the issue is simply that name has no getter...

Peter

Tim Barclay

unread,
May 25, 2018, 6:31:51 AM5/25/18
to scala-graph
Ah, you're quite right of course, it was my own ineptitude. Thanks for noticing that, it works if I change Relationship to
sealed abstract class Relationship(val name: String)

empen...@gmail.com

unread,
May 1, 2023, 11:11:03 AM5/1/23
to scala-graph
Btw, predefined labeled edges have been superseded by easy-to-define custom edges in version 2.
Reply all
Reply to author
Forward
0 new messages