This pre-check must return Abort
if the addition is to be canceled, PostCheck
if postAdd
is to be called to decide or Complete
if the outer edge
is allowed to be added.
This pre-check must return Abort
if the addition is to be canceled, PostCheck
if postAdd
is to be called to decide or Complete
if the outer edge
is allowed to be added.
If postAdd
has been implemented, this method may always return PostCheck
.
This pre-check may be omitted by letting it always return postCheck
and overriding the corresponding post-check commit*
method.
Use self
to access the associated graph.
to be added.
The results of the pre-check containing the follow-up activity
and possible any intermediate computation results to be used during the
post-check. To add computation results PreCheckResult
must be extended.
This pre-check must return Abort
if the addition is to be canceled, PostCheck
if postAdd
is to be called to decide or Complete
if the outer node
is allowed to be added.
This pre-check must return Abort
if the addition is to be canceled, PostCheck
if postAdd
is to be called to decide or Complete
if the outer node
is allowed to be added.
If postAdd
has been implemented, this method may always return PostCheck
.
This pre-check may be omitted by letting it always return postCheck
and overriding the corresponding post-check commit*
method.
Use self
to access the associated graph.
to be added
The results of the pre-check containing the follow-up activity
and possible any intermediate computation results to be used during the
post-check. To add computation results PreCheckResult
must be extended.
This pre-check must return Abort
if the subtraction of edge
is to be canceled,
PostCheck
if postSubtract
is to be called to decide or
Complete
if the the edge
is allowed to be subtracted.
This pre-check must return Abort
if the subtraction of edge
is to be canceled,
PostCheck
if postSubtract
is to be called to decide or
Complete
if the the edge
is allowed to be subtracted.
This pre-check may be omitted by letting it always return postCheck
and overriding the corresponding post-check commit*
method.
Use self
to access the associated graph.
the inner edge to be subtracted.
true
for standard (edge-only by -
),
false
for ripple (by -!
) removal.
The results of the pre-check containing the follow-up activity
and possible any intermediate computation results to be used during the
post-check. To add computation results PreCheckResult
must be extended.
This pre-check must return Abort
if the subtraction of node
is to be canceled,
PostCheck
if postSubtract
is to be called to decide or
Complete
if the the node
is allowed to be subtracted.
This pre-check must return Abort
if the subtraction of node
is to be canceled,
PostCheck
if postSubtract
is to be called to decide or
Complete
if the the node
is allowed to be subtracted.
This pre-check may be omitted by letting it always return postCheck
and overriding the corresponding post-check commit*
method.
Use self
to access the associated graph.
the inner to be subtracted.
true
for standard (ripple by -
), false
for gentle (by -?
) removal.
The results of the pre-check containing the follow-up activity
and possible any intermediate computation results to be used during the
post-check. To add computation results PreCheckResult
must be extended.
When extending Constraint
, self
will denote the attached constrained graph.
When extending Constraint
, self
will denote the attached constrained graph.
The factory methods of the companion object scalax.collection.constrained.Graph
initialize self
to the correct graph instance.
When extending Constrained
, self
will denote this
graph.
Consolidates all inner nodes of the arguments by adding the edge ends
of passedEdges
to passedNodes
.
Consolidates all inner nodes of the arguments by adding the edge ends
of passedEdges
to passedNodes
.
Consolidates all outer nodes of the arguments by adding the edge ends
of passedEdges
to passedNodes
.
Consolidates all outer nodes of the arguments by adding the edge ends
of passedEdges
to passedNodes
.
This post-check must return whether newGraph
should be committed or the add
operation is to be rolled back.
This post-check must return whether newGraph
should be committed or the add
operation is to be rolled back.
Use self
to access the associated graph.
For immutable graphs, self
maintains the state before the
addition but for mutable graphs, it is already mutated to the required state.
the after-addition would-be graph waiting for commit.
nodes passed to the running add operation except those coming from node/edge input streams.
edges passed to the running add operation except those coming from edge input streams.
This post-check must return whether newGraph
should be committed or the subtraction
is to be rolled back.
This post-check must return whether newGraph
should be committed or the subtraction
is to be rolled back.
Use self
to access the associated graph.
For immutable graphs, self
maintains the state before the
addition but for mutable graphs, it is already mutated to the required state.
the after-subtraction would-be graph waiting for commit.
This pre-check must return Abort
if the addition of the outer nodes and/or edges in elems
is to be canceled, PostCheck
if postAdd
is to be called to decide or
Complete
if the the outer nodes and/or edges are allowed to be added.
This pre-check must return Abort
if the addition of the outer nodes and/or edges in elems
is to be canceled, PostCheck
if postAdd
is to be called to decide or
Complete
if the the outer nodes and/or edges are allowed to be added.
If postAdd
has been implemented, this method may always return PostCheck
.
The default implementation calls preAdd(node)
/preAdd(edge)
element-wise.
As for most cases this won't be satisfactory a domain-specific implementation should
be provided.
Use self
to access the associated graph.
nodes and/or edges to be added possibly containing duplicates.
The results of the pre-check containing the follow-up activity
and possible any intermediate computation results to be used during the
post-check. To add computation results PreCheckResult
must be extended.
This pre-check is called on constructing a graph through its companion object.
This pre-check is called on constructing a graph through its companion object.
It must return whether the graph is allowed to be populated with nodes
and edges
.
The default implementation calls preAdd
for each node and edge.
Note that nodes and edges coming from node/edge input streams are not checked.
So when utilizing streams the post check postAdd
must be served.
the outer nodes the graph is to be populated with; nodes
being edge ends may but need not be contained in nodes
.
the outer edges the graph is to be populated with.
The results of the pre-check containing the follow-up activity
and possible any intermediate computation results to be used during the
post-check. To add computation results PreCheckResult
must be extended.
This pre-check must return Abort
if the subtraction of nodes
and/or edges
is to be canceled, PostCheck
if postSubtract
is to be called to decide or
Complete
if nodes
and/or edges
are allowed to be subtracted.
This pre-check must return Abort
if the subtraction of nodes
and/or edges
is to be canceled, PostCheck
if postSubtract
is to be called to decide or
Complete
if nodes
and/or edges
are allowed to be subtracted.
It is typically triggered by the --
operation.
The default implementation element-wise calls preSubtract(node, simple)
or
preSubtract(edge, simple)
, respectively.
As for most cases this won't be satisfactory a domain-specific implementation
should be provided.
Use self
to access the associated graph.
the inner nodes to be subtracted not necessarily including the ends of edges to be subtracted. Call allNodes to get the complete set of nodes to be subtracted.
the inner edges to be subtracted.
true
for standard (edge-only by -
),
false
for ripple (by -!
) removal.
The results of the pre-check containing the follow-up activity
and possible any intermediate computation results to be used during the
post-check. To add computation results PreCheckResult
must be extended.
This template contains all methods that constrained graphs call to decide whether operations altering a mutable graph or operations yielding a new graph from an immutable or mutable graph are valid.
Constraint methods are called on graph creation and node/edge addition and subtraction at two points of time, respectively: prior to the operation and after the operation has taken place but still may be rolled back. Thus, constraint method names are prefixed by
pre
orpost
. Pre-ckecks returnAbort
,PostCheck
orComplete
while post-checks return Boolean stating whether the operation should be committed or rolled back. Pre-checks can inspect the operands only. In contrast, post-checks additionally allow to inspect the would-be graph after the operation has taken place but has not yet been committed.For performance reasons, implementations should prefer implementing pre-check methods. If it's necessary to check not only the operands but the whole would-be graph, the appropriate post-check methods should be overridden.