GraphBuilder

com.phasmidsoftware.gryphon.builder.GraphBuilder
See theGraphBuilder companion object
class GraphBuilder[V, E, G <: Graph[V]](build: Seq[Triplet[V, E, EdgeType]] => Try[G])(using evidence$1: Parseable[V], evidence$2: Parseable[E])

A purely functional builder that constructs a typed graph from a resource file or file-system path, using the GraphParser / Parseable infrastructure.

GraphBuilder is parameterised on the vertex type V, edge type E, and the concrete graph type G. Callers obtain an instance via the companion-object factory methods GraphBuilder.undirected and GraphBuilder.directed, which supply the appropriate triplesToTryGraph function for each graph flavour.

The two Parseable context bounds are satisfied automatically for the built-in types Int, Double, String, etc., and can be provided by the caller for custom domain types (e.g. Building, TunnelProperties).

Type parameters

E

the edge attribute type.

G

the concrete graph type, must be a subtype of Graph[V].

V

the vertex attribute type.

Value parameters

build

a function that converts a sequence of parsed triplets into a Try[G].

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def fromFile(path: String): Try[G]

Builds a graph by reading from a file-system path.

Builds a graph by reading from a file-system path.

Value parameters

path

the absolute or relative path to the graph file.

Attributes

Returns

Success(G) if the file is found and parses cleanly; Failure otherwise.

def fromResource(resourceName: String): Try[G]

Builds a graph by reading from a classpath resource.

Builds a graph by reading from a classpath resource.

Value parameters

resourceName

the name of the resource file (e.g. "prim.graph").

Attributes

Returns

Success(G) if the file is found and parses cleanly; Failure otherwise.