JournaledVisitor

com.phasmidsoftware.visitor.core.JournaledVisitor
See theJournaledVisitor companion object
case class JournaledVisitor[V, R, J <: Appendable[(V, Option[R])]](journal: J, cameFromJournal: Option[CameFromJournal[V]] = ...) extends Visitor[V, R, J]

Canonical immutable implementation of Visitor.

Optionally carries a CameFromJournal for tracking came-from relationships. When cameFromJournal is non-empty, discover records (v, cameFrom) pairs. The start vertex is absent from the came-from map — it has no predecessor.

Use the factory methods on the companion object to construct instances.

Value parameters

cameFromJournal

optionally, a journal recording came-from relationships.

journal

the visit journal (ListJournal or QueueJournal).

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Visitor[V, R, J]
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def cameFrom: Option[Map[V, V]]

Returns the came-from map, if came-from tracking was enabled.

Returns the came-from map, if came-from tracking was enabled.

Attributes

Returns

Some(map) if this visitor was created with a came-from journal, None otherwise.

override def discover(v: V, cameFrom: V): JournaledVisitor[V, R, J]

Called when vertex v is discovered as a neighbour of cameFrom. Default: no-op. Override to record came-from relationships.

Called when vertex v is discovered as a neighbour of cameFrom. Default: no-op. Override to record came-from relationships.

Value parameters

cameFrom

the vertex being visited when v was discovered.

v

the newly discovered vertex.

Attributes

Returns

an updated visitor.

Definition Classes
def visit(v: V)(using ev: Evaluable[V, R]): JournaledVisitor[V, R, J]

Visits a vertex v, evaluates it using the implicit Evaluable instance, and records the result in the journal. The visitor is returned after the operation with an updated state.

Visits a vertex v, evaluates it using the implicit Evaluable instance, and records the result in the journal. The visitor is returned after the operation with an updated state.

Value parameters

ev

the implicit Evaluable instance to extract a result of type R from the vertex v.

v

the vertex to be visited.

Attributes

Returns

the updated Visitor after the vertex is processed, with its journal containing the new (v, Option[R]) entry.

Inherited methods

def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product
def result: J

Public accessor for the traversal result. Defaults to journal. Override to apply post-processing before returning results to callers.

Public accessor for the traversal result. Defaults to journal. Override to apply post-processing before returning results to callers.

Attributes

Inherited from:
Visitor