Skip to content

Instantly share code, notes, and snippets.

@satyagraha
Created February 20, 2014 21:21
Show Gist options
  • Save satyagraha/9123429 to your computer and use it in GitHub Desktop.
Save satyagraha/9123429 to your computer and use it in GitHub Desktop.
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