Class SparseTCGraph<E extends Edge>
- Type Parameters:
E- concrete type of temporal constraints stored as edges
- All Implemented Interfaces:
TemporalConstraintGraph<E>, PropertyChangeListener, EventListener
The representation stores only existing edges. It maintains an index by edge name, a directed
endpoint index, and incoming/outgoing edge-entry indexes for every vertex. Consequently, endpoint
lookup and edge lookup are expected O(1), while enumerating the incident edges of a
vertex is O(degree(vertex)). This is the intended representation for the usual CSTNU
workload: hundreds or thousands of time-points and a small number of constraints per
time-point.
This class deliberately does not implement a JUNG interface. DenseTCGraph remains the
JUNG-compatible implementation needed by the current editor. SparseTCGraph is not intended
as a replacement for that editor-facing graph, nor as an optimized representation for genuinely
dense networks.
As in DenseTCGraph, an edge name and an ordered endpoint pair must each be unique. Vertex
identity in the graph is its name: methods receiving a LabeledNode resolve it through
AbstractComponent.getName(). Clients must therefore not rename a vertex or an edge while it is
contained in this graph.
- Author:
- posenato
-
Nested Class Summary
Nested classes/interfaces inherited from interface TemporalConstraintGraph
TemporalConstraintGraph.EdgeAndNode<E>Modifier and TypeInterfaceDescriptionstatic final recordTemporalConstraintGraph.EdgeAndNode<E extends Edge>An edge paired with the canonical vertex at the opposite end of a traversal. -
Constructor Summary
ConstructorsModifierConstructorDescription<E1 extends E>SparseTCGraph(String graphName, Class<E1> inputEdgeImplClass) Creates an empty sparse temporal constraint graph. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAnnotation(GraphAnnotation annotation) Adds a presentation-only plain-text annotation to this graph.booleanaddEdge(E edge, LabeledNode source, LabeledNode destination) Adds an edge, adding missing endpoints first.voidAdds an edge between vertices identified by name, creating ordinary vertices when necessary.booleanaddVertex(LabeledNode vertex) Adds a vertex with a unique name.voidclear()Removes every vertex, edge, and the distinguished zero time-point.voidRemoves every presentation-only annotation from this graph.voidInvalidates snapshots and rebuilds the contingent-edge index without changing graph content.booleancontainsEdge(E edge) Tests whether this graph contains an edge whose name matches the name of the supplied edge.booleancontainsVertex(LabeledNode vertex) Finds the directed edge identified by its endpoint names, ornull.Returns the annotations in their drawing order.intReturns half the maintained contingent-edge count, matchingDenseTCGraph's historical contingent-link convention.Returns the destination endpoint of the edge identified by the supplied edge's name.Returns the edge havingedgeName, ornullwhen absent.intReturns the concrete class that this graph uses to instantiate its edges.getEdges()getInEdges(LabeledNode vertex) getInEdgesAndSources(LabeledNode vertex) Returns an unmodifiable snapshot of pairs(edge, canonical source)for all incoming edges ofvertex.getName()Returns the time-point withname, ornullwhen absent.getObserver(char proposition) getOutEdges(LabeledNode vertex) Returns an unmodifiable snapshot of pairs(edge, canonical destination)for all outgoing edges ofvertex.it.unimi.dsi.fastutil.chars.CharSetReturns the source endpoint of the edge identified by the supplied edge's name.getType()intgetZ()intinDegree(LabeledNode vertex) newEdgeInstance(String edgeName, Edge.ConstraintType edgeType) Creates an edge instance without reserving or normalizing its name against this graph.newInstance(String inputName, int initialCapacity) Creates a new, empty temporal-constraint graph with the same concrete backend and the same concrete edge implementation as this graph.<F extends Edge, I extends F>
SparseTCGraph<F> newInstance(String inputName, Class<I> edgeImplClass, int initialCapacity) Creates a new, empty graph of the same concrete backend as this graph, but with a different edge implementation.Creates an empty predecessor-relation container suitable for algorithms running on this graph.intoutDegree(LabeledNode vertex) voidMaintains the observer index when a stored node changes its observed proposition.voidremoveAnnotation(GraphAnnotation annotation) Removes a presentation-only annotation from this graph.booleanremoveEdge(String edgeName) Removes an edge by name.booleanremoveVertex(LabeledNode vertex) Removes a time-point and all its incident edges.voidrenameEdge(E edge, String newName) Renames an edge already contained in this graph, atomically, inO(1)time beyond the usual name-keyed cache invalidation.voidrenameNode(LabeledNode node, String newName) Renames a node already contained in this graph, atomically.voidreplaceContentsFrom(TemporalConstraintGraph<E> source) Replaces this graph's contents with those ofsource, which must use the same concrete backend and edge implementation.voidsetCheckOutcome(CheckOutcome outcome) Sets or clears the persisted check result.voidSets or clears the persisted dispatchability representation.voidsetInputFile(File newInputFile) Associates this graph with its input file for diagnostics and benchmark reporting.voidSets the graph name.voidsetType(TemporalConstraintNetworkType newType) Declares the temporal-network kind represented by this graph.voidsetZ(LabeledNode newZ) Sets the distinguished zero time-point, or clears it whenzisnull.voidReverses every directed edge while retaining the same edge objects and names.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface TemporalConstraintGraph
clearOutcomes, copyCleaningRedundantLabels, findEdge, getChildrenOf, getObserver2ZEdges, getObserverCount, getPredecessors, getSuccessors, getUniqueEdgeName, getVerticesArray, hasSameEdgesOf, makeNewEdge, newInstance, ownsEdge, ownsNode, promoteToPCSTNUIfParameter, recordCheckOutcome, recordDispatchabilityOutcome, removeEdge, removeEmptyEdges, rewriteALetterReferencesModifier and TypeMethodDescriptiondefault voidClears both the persisted check result and the persisted dispatchability representation.default voidPopulates this (initially empty) graph as a copy ofsource, dropping labeled values whose label contains the unknown literal or whose value isConstants.INT_NEG_INFINITE, and dropping edges left empty by this filtering.default EfindEdge(LabeledNode source, LabeledNode destination) Finds the directed edge fromsourcetodestination, ornull.default LabelgetChildrenOf(LabeledNode obs) Given an observerobsof proposition p, its "children" are all observers Q for which p appears in the label of Q.default it.unimi.dsi.fastutil.objects.ObjectList<E> default intdefault Collection<LabeledNode> getPredecessors(LabeledNode vertex) default Collection<LabeledNode> getSuccessors(LabeledNode vertex) default StringgetUniqueEdgeName(String edgeName) ReturnsedgeNamewhen available; otherwise appends the first available suffix among_0,_1, and so on.default LabeledNode[]default booleanhasSameEdgesOf(TemporalConstraintGraph<E> other) Returnstrueif this graph contains the same set of edges asother.default EmakeNewEdge(String edgeName, Edge.ConstraintType edgeType) Creates a new edge suitable for this graph, with a non-conflicting name and the requested constraint type.default TemporalConstraintGraph<E> newInstance(TemporalConstraintGraph<E> source) Creates a new graph with this graph's concrete backend and edge implementation, containing a faithful copy ofsource.default booleantrueif and only if the supplied edge object is the same object stored in this graph (compared by identity, not by name).default booleanownsNode(LabeledNode node) trueif and only if the supplied node object is the same object stored in this graph (compared by identity, not by name).default voidMakes this graph a PCSTNU whennodeis a parameter one and the graph still calls itself a CSTNU.default voidrecordCheckOutcome(CheckOutcome.Kind kind, boolean successful, String algorithm) Builds and stores aCheckOutcome, stamped withCheckOutcome.currentToolVersion().default voidrecordDispatchabilityOutcome(DispatchabilityOutcome.Status status, String algorithm) Builds and stores aDispatchabilityOutcome.default booleanremoveEdge(E edge) Removes an edge by object.default booleanRemoves all edges that are considered "empty" (e.g., have a null value or are otherwise invalid).default voidrewriteALetterReferences(ALabelAlphabet.ALetter oldLetter, ALabelAlphabet.ALetter newLetter) Rewrites every A-Label-based semantic reference tooldLetter, throughout this graph, intonewLetter.
-
Constructor Details
-
SparseTCGraph
public <E1 extends E> SparseTCGraph(@Nonnull String graphName, @Nonnull Class<E1> inputEdgeImplClass) Creates an empty sparse temporal constraint graph.- Type Parameters:
E1- concrete edge type, possibly narrower thanE- Parameters:
graphName- name used for diagnosticsinputEdgeImplClass- concrete edge implementation to create fromTemporalConstraintGraph.makeNewEdge(String, Edge.ConstraintType)
-
-
Method Details
-
addAnnotation
Description copied from interface:TemporalConstraintGraphAdds a presentation-only plain-text annotation to this graph.- Specified by:
addAnnotationin interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
annotation- the annotation to add
-
addEdge
public boolean addEdge(@Nonnull E edge, @Nonnull LabeledNode source, @Nonnull LabeledNode destination) Adds an edge, adding missing endpoints first. An edge name and its ordered endpoint pair must both be unused.- Specified by:
addEdgein interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
edge- edge to addsource- source endpointdestination- destination endpoint- Returns:
trueif the graph changed- Throws:
IllegalArgumentException- if an edge name or endpoint pair is already present
-
addEdge
Adds an edge between vertices identified by name, creating ordinary vertices when necessary.- Specified by:
addEdgein interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
edge- edge to addsourceName- source endpoint namedestinationName- destination endpoint name- Throws:
IllegalArgumentException- if an edge name or endpoint pair is already present
-
addVertex
Adds a vertex with a unique name.- Specified by:
addVertexin interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
vertex- time-point to add- Returns:
trueif the graph changed- Throws:
IllegalArgumentException- if the name is already present or another vertex observes the same proposition
-
clear
public void clear()Removes every vertex, edge, and the distinguished zero time-point.- Specified by:
clearin interfaceTemporalConstraintGraph<E extends Edge>
-
clearAnnotations
public void clearAnnotations()Description copied from interface:TemporalConstraintGraphRemoves every presentation-only annotation from this graph.- Specified by:
clearAnnotationsin interfaceTemporalConstraintGraph<E extends Edge>
-
clearCache
public void clearCache()Invalidates snapshots and rebuilds the contingent-edge index without changing graph content.- Specified by:
clearCachein interfaceTemporalConstraintGraph<E extends Edge>
-
containsEdge
Description copied from interface:TemporalConstraintGraphTests whether this graph contains an edge whose name matches the name of the supplied edge.Identification is by name, within this graph: this method looks up the edge by
the edge's nameand does not compare the supplied object by identity. Querying with an edge that belongs to a different graph but whose name coincides with a local edge returnstrueand resolves to the local element, notfalse.To test whether a specific edge object is the one actually stored in this graph (by identity, not by name), use
ownsEdge.- Specified by:
containsEdgein interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
edge- edge to test- Returns:
- whether there is an edge with the given name in this graph
-
containsVertex
- Specified by:
containsVertexin interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
vertex- time-point to test- Returns:
- whether the time-point belongs to this graph
-
findEdge
Description copied from interface:TemporalConstraintGraphFinds the directed edge identified by its endpoint names, ornull.- Specified by:
findEdgein interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
sourceName- source endpoint name, possiblynulldestinationName- destination endpoint name, possiblynull- Returns:
- matching edge, or
nullwhen absent
-
getALabelAlphabet
- Specified by:
getALabelAlphabetin interfaceTemporalConstraintGraph<E extends Edge>- Returns:
- the shared alphabet used for contingent-node A-Labels, or
nullfor network kinds that do not use upper/lower-case values (e.g., plain CSTN)
-
getAnnotations
Description copied from interface:TemporalConstraintGraphReturns the annotations in their drawing order. The returned list must not be modified directly.- Specified by:
getAnnotationsin interfaceTemporalConstraintGraph<E extends Edge>- Returns:
- the annotations in their drawing order
-
getContingentNodeCount
public int getContingentNodeCount()Returns half the maintained contingent-edge count, matchingDenseTCGraph's historical contingent-link convention.- Specified by:
getContingentNodeCountin interfaceTemporalConstraintGraph<E extends Edge>- Returns:
- the number of contingent links, namely half the number of contingent edges
-
getDest
Description copied from interface:TemporalConstraintGraphReturns the destination endpoint of the edge identified by the supplied edge's name.Identification is by name, within this graph: the supplied edge's name is used to look up the local edge, and the destination node of that local edge is returned. Querying with an edge that belongs to a different graph but whose name coincides with a local edge returns the local destination node, not
null.To test whether a specific edge object is the one actually stored in this graph, use
ownsEdge.- Specified by:
getDestin interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
edge- edge whose destination endpoint is requested- Returns:
- the node whose name matches the destination endpoint of the edge,
or
nullif the edge is absent
-
getEdge
Description copied from interface:TemporalConstraintGraphReturns the edge havingedgeName, ornullwhen absent.- Specified by:
getEdgein interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
edgeName- edge name- Returns:
- matching edge, or
nullwhen absent
-
getEdgeCount
public int getEdgeCount()- Specified by:
getEdgeCountin interfaceTemporalConstraintGraph<E extends Edge>- Returns:
- the number of edges
-
getEdgeImplClass
Returns the concrete class that this graph uses to instantiate its edges.Every edge created by
TemporalConstraintGraph.newEdgeInstance(String, Edge.ConstraintType)orTemporalConstraintGraph.makeNewEdge(String, Edge.ConstraintType)belongs to this class. Callers that need to construct a companion graph with the same edge implementation — for example when copying or converting a graph — can pass the returned class directly toTemporalConstraintGraph.newInstance(String, Class, int).Delegates to the internal edge factory of this graph.
- Specified by:
getEdgeImplClassin interfaceTemporalConstraintGraph<E extends Edge>- Returns:
- concrete edge implementation class; never
null
-
getEdges
- Specified by:
getEdgesin interfaceTemporalConstraintGraph<E extends Edge>- Returns:
- an independent collection containing all edges
-
getInEdges
- Specified by:
getInEdgesin interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
vertex- time-point whose incoming edges are requested- Returns:
- incoming edges of
vertex, or an empty collection if absent or isolated
-
getInEdgesAndSources
@Nonnull public Collection<TemporalConstraintGraph.EdgeAndNode<E>> getInEdgesAndSources(@Nonnull LabeledNode vertex) Description copied from interface:TemporalConstraintGraphReturns an unmodifiable snapshot of pairs(edge, canonical source)for all incoming edges ofvertex. The node in each pair is the canonical source stored in this graph. An absent or isolated vertex returns an empty collection. Iteration order is not contractual, but is deterministic for each backend; construction is proportional to the vertex degree.- Specified by:
getInEdgesAndSourcesin interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
vertex- time-point whose incoming edges are requested- Returns:
- immutable snapshot of incoming edge/source pairs
-
getInputFile
- Specified by:
getInputFilein interfaceTemporalConstraintGraph<E extends Edge>- Returns:
- the file from which this graph was read, or
nullwhen unavailable
-
setInputFile
Associates this graph with its input file for diagnostics and benchmark reporting.- Specified by:
setInputFilein interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
newInputFile- input file, ornullto clear the association
-
getName
- Specified by:
getNamein interfaceTemporalConstraintGraph<E extends Edge>- Returns:
- the graph name used in diagnostics and serialized representations
-
setName
Sets the graph name.- Specified by:
setNamein interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
inputName- the new name for the graph.
-
getNode
Description copied from interface:TemporalConstraintGraphReturns the time-point withname, ornullwhen absent.- Specified by:
getNodein interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
nodeName- time-point name- Returns:
- matching time-point, or
nullwhen absent
-
getObserver
- Specified by:
getObserverin interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
proposition- a proposition- Returns:
- the vertex observing
proposition, ornullif no vertex does
-
getObservers
- Specified by:
getObserversin interfaceTemporalConstraintGraph<E extends Edge>- Returns:
- every observer vertex in this graph, i.e., every vertex associated with an observed proposition
-
getOutEdges
- Specified by:
getOutEdgesin interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
vertex- time-point whose outgoing edges are requested- Returns:
- outgoing edges of
vertex, or an empty collection if absent or isolated
-
getOutEdgesAndDestinations
@Nonnull public Collection<TemporalConstraintGraph.EdgeAndNode<E>> getOutEdgesAndDestinations(@Nonnull LabeledNode vertex) Description copied from interface:TemporalConstraintGraphReturns an unmodifiable snapshot of pairs(edge, canonical destination)for all outgoing edges ofvertex. The node in each pair is the canonical destination stored in this graph. An absent or isolated vertex returns an empty collection. Iteration order is not contractual, but is deterministic for each backend; construction is proportional to the vertex degree.- Specified by:
getOutEdgesAndDestinationsin interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
vertex- time-point whose outgoing edges are requested- Returns:
- immutable snapshot of outgoing edge/destination pairs
-
getPropositions
@Nonnull public it.unimi.dsi.fastutil.chars.CharSet getPropositions()- Specified by:
getPropositionsin interfaceTemporalConstraintGraph<E extends Edge>- Returns:
- the propositions observed by nodes in this graph
-
getSource
Description copied from interface:TemporalConstraintGraphReturns the source endpoint of the edge identified by the supplied edge's name.Identification is by name, within this graph: the supplied edge's name is used to look up the local edge, and the source node of that local edge is returned. Querying with an edge that belongs to a different graph but whose name coincides with a local edge returns the local source node, not
null.To test whether a specific edge object is the one actually stored in this graph, use
ownsEdge.- Specified by:
getSourcein interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
edge- edge whose source endpoint is requested- Returns:
- the node whose name matches the source endpoint of the edge,
or
nullif the edge is absent
-
getType
- Specified by:
getTypein interfaceTemporalConstraintGraph<E extends Edge>- Returns:
- the temporal-network kind represented by this graph
-
getCheckOutcome
- Specified by:
getCheckOutcomein interfaceTemporalConstraintGraph<E extends Edge>- Returns:
- the persisted check result, or
nullwhen no trusted result is available.
-
getDispatchabilityOutcome
- Specified by:
getDispatchabilityOutcomein interfaceTemporalConstraintGraph<E extends Edge>- Returns:
- the persisted dispatchability representation, or
nullwhen absent.
-
setCheckOutcome
Description copied from interface:TemporalConstraintGraphSets or clears the persisted check result.- Specified by:
setCheckOutcomein interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
outcome- the check outcome to store, ornullto clear
-
setDispatchabilityOutcome
Description copied from interface:TemporalConstraintGraphSets or clears the persisted dispatchability representation.- Specified by:
setDispatchabilityOutcomein interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
outcome- the dispatchability outcome to store, ornullto clear
-
setType
Description copied from interface:TemporalConstraintGraphDeclares the temporal-network kind represented by this graph.A graph infers its kind from its edge implementation at construction time, and for most kinds that is enough. Two kinds cannot be inferred that way, because they share their edge implementation with another kind: a
PCSTNUuses the same edges as aCSTNUand differs by having parameter nodes, and aPSTNuses the same edges as anSTNU. For those two the caller has to say so — which is what this method is for, and it is the reason it belongs here rather than to one concrete backend: whoever creates a PCSTNU must be able to declare it whichever backend it lives on.Only such an ambiguity may be resolved: a request to change the kind into one that this graph's edges cannot represent is rejected with an
IllegalArgumentException, since it would make the graph describe itself as something it cannot be. UseTemporalConstraintGraph.isTypeChangeAllowed(TemporalConstraintNetworkType, TemporalConstraintNetworkType)to ask in advance. Anullargument is ignored.- Specified by:
setTypein interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
newType- the kind this graph represents
-
getVertexCount
public int getVertexCount()- Specified by:
getVertexCountin interfaceTemporalConstraintGraph<E extends Edge>- Returns:
- the number of time-points
-
getVertices
- Specified by:
getVerticesin interfaceTemporalConstraintGraph<E extends Edge>- Returns:
- all time-points in the graph
-
getZ
- Specified by:
getZin interfaceTemporalConstraintGraph<E extends Edge>- Returns:
- the distinguished zero time-point, or
nullwhen it is not set
-
setZ
Description copied from interface:TemporalConstraintGraphSets the distinguished zero time-point, or clears it whenzisnull.- Specified by:
setZin interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
newZ- zero time-point, ornullto clear it
-
inDegree
- Specified by:
inDegreein interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
vertex- time-point whose incoming degree is requested- Returns:
- number of incoming edges
-
newEdgeInstance
Description copied from interface:TemporalConstraintGraphCreates an edge instance without reserving or normalizing its name against this graph. This is intended for temporary edges that have not yet been inserted into a graph.- Specified by:
newEdgeInstancein interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
edgeName- the name for the new edgeedgeType- the type for the new edge- Returns:
- the new edge object
-
newInstance
Creates a new, empty temporal-constraint graph with the same concrete backend and the same concrete edge implementation as this graph.This lets an algorithm that only knows
TemporalConstraintGraph<E>create a companion graph (e.g., a predecessor subgraph) without naming a concrete class such asDenseTCGraphorSparseTCGraph, without aClass<? extends E>parameter, and without a builder: every implementation already knows its own concrete backend and edge type, so it returns an instance of itself. Consequently, calling this method on aDenseTCGraphyields aDenseTCGraph, and calling it onSparseTCGraphyields aSparseTCGraph.The returned graph has no vertices, no edges, no distinguished zero time-point, and no cached data: it does not copy anything from this graph, it is only "the same kind of empty graph".
Returns a new
SparseTCGraphwith the same concrete edge implementation as this graph.SparseTCGraphdoes not yet have a capacity-aware constructor (its indexes are hash-based and grow on demand), soinitialCapacityis accepted for API symmetry withDenseTCGraphand is currently ignored.- Specified by:
newInstancein interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
inputName- new graph's name, for diagnosticsinitialCapacity- expected vertex count, used as a pre-sizing hint by implementations whose internal storage benefits from it (e.g.,DenseTCGraph's adjacency matrix, to avoid intermediate regrowth); implementations without a capacity-aware constructor may ignore it- Returns:
- a new, empty graph of the same concrete backend and edge implementation as this graph
-
newInstance
@Nonnull public <F extends Edge, I extends F> SparseTCGraph<F> newInstance(@Nonnull String inputName, @Nonnull Class<I> edgeImplClass, int initialCapacity) Creates a new, empty graph of the same concrete backend as this graph, but with a different edge implementation.This is the overload to use when an algorithm must translate a network from one edge kind to another (e.g., a CSTNU-edge graph reduced to a CSTN-edge graph) while still preserving the caller's choice of backend (
DenseTCGraphstaysDenseTCGraph,SparseTCGraphstaysSparseTCGraph). It does not copy anything from this graph: no vertices, no edges, no distinguished zero time-point, and no cached data.Returns a new
SparseTCGraphusingedgeImplClass.initialCapacityis accepted for API symmetry withDenseTCGraphand is currently ignored, as withnewInstance(String, int).- Specified by:
newInstancein interfaceTemporalConstraintGraph<E extends Edge>- Type Parameters:
F- the new graph's API-level edge type (e.g.,CSTNEdge)I- the concrete edge implementation, a subtype ofF(e.g.,CSTNEdgePluggable); kept distinct fromFso that callers can assign the result to aTemporalConstraintGraph<F>variable without an unchecked cast, whileedgeImplClassstays the concrete, instantiable class- Parameters:
inputName- new graph's name, for diagnosticsedgeImplClass- concrete edge implementation for the new graphinitialCapacity- expected vertex count, used as a pre-sizing hint by implementations whose internal storage benefits from it (e.g.,DenseTCGraph's adjacency matrix); implementations without a capacity-aware constructor may ignore it- Returns:
- a new, empty graph of the same concrete backend as this graph and of the requested edge type
-
newPredecessorInstance
Description copied from interface:TemporalConstraintGraphCreates an empty predecessor-relation container suitable for algorithms running on this graph.The returned object is independent of this graph. Its representation is an implementation detail: graph backends may share a compact predecessor container when that is more efficient. This factory keeps algorithm code independent of that choice.
- Specified by:
newPredecessorInstancein interfaceTemporalConstraintGraph<E extends Edge>- Returns:
- a new, empty predecessor-relation container
-
outDegree
- Specified by:
outDegreein interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
vertex- time-point whose outgoing degree is requested- Returns:
- number of outgoing edges
-
propertyChange
Maintains the observer index when a stored node changes its observed proposition.Both lookup and mutation remain expected
O(1): the previous and proposed propositions address the index directly, avoiding a scan of the graph's vertices.- Specified by:
propertyChangein interfacePropertyChangeListener
-
removeAnnotation
Description copied from interface:TemporalConstraintGraphRemoves a presentation-only annotation from this graph.- Specified by:
removeAnnotationin interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
annotation- annotation to remove
-
removeEdge
Description copied from interface:TemporalConstraintGraphRemoves an edge by name.- Specified by:
removeEdgein interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
edgeName- name of the edge to remove- Returns:
trueif the graph changed
-
removeVertex
Description copied from interface:TemporalConstraintGraphRemoves a time-point and all its incident edges.- Specified by:
removeVertexin interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
vertex- time-point to remove- Returns:
trueif the graph changed
-
renameEdge
Renames an edge already contained in this graph, atomically, inO(1)time beyond the usual name-keyed cache invalidation.On success, the edge-name index (and any other name-keyed structure of this graph) is updated. The edge's endpoints, constraint type, and values are left untouched: an edge's name carries no semantic reference elsewhere (unlike a node's, see
TemporalConstraintGraph.renameNode(LabeledNode, String)), so no further rewrite is needed.On failure, this graph and the edge are left exactly as they were: this method validates before mutating anything. This is the only supported way to rename an edge already added to a graph;
Component.setName(String)rejects a direct call once the edge has been added.Re-keys every edge-name-keyed sparse index in place, preserving both the stored edge object and this graph's edge-enumeration order (
getEdges()iteratesedgesByNameitself). Runs inO(degree)of the edge's two endpoints, beyond theO(1)name-index update.- Specified by:
renameEdgein interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
edge- an edge already contained in this graphnewName- the new, non-empty, not-already-used name
-
renameNode
Renames a node already contained in this graph, atomically.On success, every structural index and name-keyed cache of this graph is updated, and every A-Label-based semantic reference to the node's old name — its own
LabeledNode.getALabel(),STNUEdge.CaseLabels, upper/lower-case labeled values, and labeled potentials that mention it — is rewritten to the new name, using each structure's own remove/merge API (seeTemporalConstraintGraph.rewriteALetterReferences(ALetter, ALetter)). The node's endpoints and every other attribute are left untouched.On failure, this graph, the node, and every structure above are left exactly as they were: this method validates before mutating anything. This is the only supported way to rename a node already added to a graph;
LabeledNode.setName(String)rejects a direct call once the node has been added (seeComponent.setName(String)).Re-keys every name-keyed sparse index in place, preserving both the stored node object and this graph's vertex-enumeration order (
getVertices()iteratesverticesByNameitself).- Specified by:
renameNodein interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
node- a node already contained in this graphnewName- the new, non-empty, not-already-used name
-
replaceContentsFrom
Replaces this graph's contents with those ofsource, which must use the same concrete backend and edge implementation. Implementations may transfer their internal representation directly when that is safe; otherwise they retain the nodes and edges while rebuilding their indexes. This operation is intended for algorithms that construct a same-backend companion graph and then install it as the result without exposing a concrete graph class.The sparse indexes are rebuilt in
O(|V| + |E|)while retaining the canonical node and edge objects. This is linear in the result size and avoids any dense intermediate graph.source'scheck outcomeanddispatchability outcomeare carried over: unlike a copy, this method installssource's already-finished content, verdict included, intothiswhile keepingthis's own object identity — exactly the case where a verdict just established onsourcemust not be silently lost.- Specified by:
replaceContentsFromin interfaceTemporalConstraintGraph<E extends Edge>- Parameters:
source- same-backend graph whose contents become this graph's contents
-
transpose
public void transpose()Reverses every directed edge while retaining the same edge objects and names.The endpoint and incidence indexes are rebuilt in
O(|E|)time; noO(|V|²)matrix traversal is performed.- Specified by:
transposein interfaceTemporalConstraintGraph<E extends Edge>
-