You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Domain Type hierarchies are not honoured in scala-graph
I just created a hierarchy of types:
abstract class RootOfAllNode {
def identifiedAs: String
}
class SubClassNodeA (id: Int) extends RootOfAllNode {
def identifiedAs = "SubCLassNodeA (" + id + ")"
}
class SubClassNodeB (price: Float) extends RootOfAllNode {
def identifiedAs = "SubClassNodeB with price (" + price + ")"
}
// DateTime is actually org.joda.time.DateTime
class SubClassNodeC (createdOn: DateTime) extends RootOfAllNode {
def identifiedAs = "SubClassNodeC (" + createdOn + ")"
}
Now, I intend to create a (Directed) Graph whose inhabitants are objects of the aforementioned types, thus:
import scalax.collection.GraphPredef._
import scalax.collection.GraphEdge._
import scalax.collection.GraphEdge.DiEdge
import scalax.collection.edge.LDiEdge // labeled directed edge
import scalax.collection.edge.Implicits._ // shortcuts
import scalax.collection.edge.LBase._
object StringLabel extends LEdgeImplicits[String]
import StringLabel._
class Population {
val a = new SubClassNodeA(9)
val anotherA = new SubClassNodeA(10)
val b = new SubClassNodeB(12.67f)
val c = new SubClassNodeC(new DateTime(System.currentTimeMillis()))
val family = Graph (
(a ~+> b)("Loves"), // Works
(b ~+> c)("Hates"), // Works
(b ~+> a)("Ignores"), // Works
(a ~+> anotherA)("notIntroducedYet") // Doesn't work
)
}
What the compiler comes back with is a mouthful! :-)
Error:(34, 8) type mismatch;
found : scalax.collection.edge.LDiEdge[org.nirmalya.graphExplore.SubClassNodeA] with scalax.collection.GraphEdge.EdgeCopy[scalax.collection.edge.LDiEdge]{type L1 = String}
required: scalax.collection.GraphPredef.Param[org.nirmalya.graphExplore.RootOfAllNode,scalax.collection.edge.LDiEdge]
Note: org.nirmalya.graphExplore.SubClassNodeA <: org.nirmalya.graphExplore.RootOfAllNode (and scalax.collection.edge.LDiEdge[org.nirmalya.graphExplore.SubClassNodeA] with scalax.collection.GraphEdge.EdgeCopy[scalax.collection.edge.LDiEdge]{type L1 = String} <: scalax.collection.GraphPredef.Param[org.nirmalya.graphExplore.SubClassNodeA,scalax.collection.edge.LDiEdge]), but trait Param is invariant in type N.
You may wish to define N as +N instead. (SLS 4.5)
(a ~+> anotherA)("notIntroducedYet")
If I create a Graph of objects of the Domain that application works in, it is quite likely that a Domain Class Hierarchy will exist. More so, because these objects will be created outside the Graph and then be held inside the Graph for easy access based on the relationships that exist between them. Therefore, somewhere, it will be expected that while it is being created, the Graph infers the Relationships between the Objects correctly.
Referring to the example I had provided, I am relating a SubClassNodeA to a SubClassNodeA, in the same way as a SubClassNodeA to a SubClassNodeB, because both of them IsARootOfAllNode . In the Application Domain, this hierarchy is established. In the Graph, this is not honoured.
The text was updated successfully, but these errors were encountered:
Domain Type hierarchies are not honoured in scala-graph
I just created a hierarchy of types:
Now, I intend to create a (Directed) Graph whose inhabitants are objects of the aforementioned types, thus:
What the compiler comes back with is a mouthful! :-)
If I create a Graph of objects of the Domain that application works in, it is quite likely that a Domain Class Hierarchy will exist. More so, because these objects will be created outside the Graph and then be held inside the Graph for easy access based on the relationships that exist between them. Therefore, somewhere, it will be expected that while it is being created, the Graph infers the Relationships between the Objects correctly.
Referring to the example I had provided, I am relating a SubClassNodeA to a SubClassNodeA, in the same way as a SubClassNodeA to a SubClassNodeB, because both of them IsA RootOfAllNode . In the Application Domain, this hierarchy is established. In the Graph, this is not honoured.
The text was updated successfully, but these errors were encountered: