Scala port of NetworkX