Created
February 20, 2014 21:21
-
-
Save satyagraha/9123429 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.test | |
import scalax.collection.immutable.Graph | |
import scalax.collection.GraphPredef._ | |
import scalax.collection.GraphEdge._ | |
object SampleGraph { | |
case class MyNode(name: String) | |
type MyEdge = DiEdge[MyNode] | |
type MyGraph = Graph[MyNode, DiEdge] | |
val name1 = MyNode("A") | |
val name2 = MyNode("B") | |
val name3 = MyNode("3") | |
val edge12 = name1 ~> name2 | |
val edge23 = name2 ~> name3 | |
val graph: MyGraph = Graph.from(List(name1, name2), List(edge12, edge23)); | |
def handleNodes(nodes: MyGraph#NodeSetT) = { | |
} | |
val filteredNodes = graph.nodes.filter(_.value.name.startsWith("A")) | |
handleNodes(filteredNodes) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment