pyCBD.depGraph module

This module implements a dependency graph

Original Author

Marc Provost

class pyCBD.depGraph.DepNode(object)[source]

Bases: object

Class implementing a node in the dependency graph.

Parameters

object – Reference to a semantic object identifying the node

mark()[source]

Marks the node.

unMark()[source]

Unmarks the node.

isMarked()[source]

Checks if the node is marked.

getMappedObj()[source]

Gets the object that this node refers to.

class pyCBD.depGraph.DepGraph(ignore_hierarchy=False)[source]

Bases: object

Class 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.

getSemanticMapping()[source]

Obtains the semantic mapping of the graph.

Returns

A dictionary of object -> DepNode.

mark(object)[source]

Marks an object in the graph.

Parameters

object – The object to mark

unMark(object)[source]

Unmarks an object in the graph.

Parameters

object – The object to unmark

isMarked(object)[source]

Checks if an object is marked in the graph.

Parameters

object – The object to check

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 CBD model to construct the graph for.

  • curIt (int) – The iteration for which the dependency graph will be constructed.