pyCBD.depGraph module¶
This module implements a dependency graph
- Original Author
Marc Provost
- class pyCBD.depGraph.DepNode(object)[source]¶
Bases:
objectClass implementing a node in the dependency graph.
- Parameters
object – Reference to a semantic object identifying the node
- class pyCBD.depGraph.DepGraph(ignore_hierarchy=False)[source]¶
Bases:
objectClass implementing dependency graph.
- addMember(object)[source]¶
Add an object mapped to this graph.
- Parameters
object – the object to be added
- Raises
ValueError – If object is already in the graph
- hasMember(object)[source]¶
Checks if the object is already mapped.
- Parameters
object – The object to be checked.
- removeMember(object)[source]¶
Remove a object from this graph.
- Parameters
object – the object to be removed
- Raises
ValueError – If object is not in the graph
- setDependency(dependent, influencer, curIt)[source]¶
Creates a dependency between two objects.
- Parameters
dependent – The object which depends on the
influencer.influencer – The object which influences the
dependent.
- Raises
ValueError – if depedent or influencer is not member of this graph
ValueError – if the dependency already exists
- hasDependency(dependent, influencer)[source]¶
Checks if the influencer influences the dependent and if the dependent is dependent on the influencer.
- Parameters
dependent – The object which depends on the other
influencer – The object which influences the other
- unsetDependency(dependent, influencer)[source]¶
Removes a dependency between two objects.
- Parameters
dependent – The object which depends on the other
influencer – The object which influences the other
- Raises
ValueError – if depedent or influencer is not member of this graph
ValueError – if the dependency does not exists
- getDependents(object)[source]¶
Obtains all dependents of a specific object.
- Parameters
object – The object to get the dependents from.
- getInfluencers(object)[source]¶
Obtains all influencers of a specific object.
- Parameters
object – The object to get the influencers from.
- pyCBD.depGraph.createDepGraph(model, curIteration, ignore_hierarchy=False)[source]¶
Create a dependency graph of the CBD model. Use the curIteration to differentiate between the first and other iterations Watch out for dependencies with sub-models.
- Parameters
model – The model for which the dependency graph must be computed.
curIteration – The current iteration for the dependency graph.
ignore_hierarchy – Assume the CBD model is flat and don’t call this recursively.
- pyCBD.depGraph.gvDepGraph(model, curIt, ignore_hierarchy=False)[source]¶
Create a Graphviz string that corresponds to the dependency graph at the given iteration cycle.
- Parameters
model (CBD) – The
CBDmodel to construct the graph for.curIt (int) – The iteration for which the dependency graph will be constructed.