For this project, I will create a src/main/scala/InfluenceDiagram.scala
file. For demo purpose, I will just recreate the graph from Chapter 2, Data Pipelines and Modeling:
import scalax.collection.Graph import scalax.collection.edge._ import scalax.collection.GraphPredef._ import scalax.collection.GraphEdge._ import scalax.collection.edge.Implicits._ object InfluenceDiagram extends App { var g = Graph[String, LDiEdge](("'Weather'"~+>"'Weather Forecast'")("Forecast"), ("'Weather Forecast'"~+>"'Vacation Activity'")("Decision"), ("'Vacation Activity'"~+>"'Satisfaction'")("Deterministic"), ("'Weather'"~+>"'Satisfaction'")("Deterministic")) println(g.mkString(";")) println(g.isDirected) println(g.isAcyclic) }
The ~+>
operator is used to create a directed labeled edge between two nodes defined in scalax/collection/edge/Implicits.scala
, which, in our case, are of the String
type. The list of other edge types and operators is provided in the following table...