Core User Guide: Introduction


This document provides an example-driven, comprehensive coverage of the functionality of Graph for Scala as part of the Extended Scala Library. In each chapter examples are listed first. You may then read the explanations following the examples to make them more coherent or skip them and go directly to the next chapter.

References to specific Graph classes in this document may be looked up in the Scaladoc API reference. This guide is not meant to be complete.

For the sake of simplicity, most examples are based on graphs spanned over nodes of the type Int. Graph customization is shown by the node type Airport and the edge type Flight.

Why Use Graph for Scala?

The most important reasons why Graph for Scala speeds up your development are:

  • Simplicity: Creating, manipulating and querying Graph is intuitive.
  • Consistency: Graph for Scala seamlessly maintains a consistent state of nodes and edges including prevention of duplicates, intelligent addition and removal.
  • Conformity: As a regular collection class, Graph has the same "look and feel" as other members of the Scala collection framework. Whenever appropriate, result types are Scala collection types themselves.
  • Flexibility: All kinds of graphs including mixed graphs, multi-graphs and hypergraphs are supported.
  • Functional Style: Graph for Scala facilitates a concise, functional style of utilizing graph functionality, including traversals, not seen in Java-based libraries.
  • Extendibility: You can easily customize Graph for Scala to reflect the needs of you application retaining all benefits of Graph.
  • Documentation: Ideal progress curve through adequate documentation.

Look and see!


Throughout the library we use the terms node as a synonym to vertex and edge as a generic term for hyperedge, line (undirected edge) or arc (directed edge).

Status of Work

Among others, Graph creation, editing, functional traversal, path operations, degree calculation and cycle detection have been completed. More functionality is due to be added. You are invited to request enhancements based on your problem domain.


  • There is no direct support for half-edges but they can be simulated by Option.
  • Neither node nor edge sets may be infinite although this could be achieved by a custom implementation.


The Graph for Scala library consists of the Core and further optional modules. Each module comes with its separate User Guide and is built as a separate Jar.