| | |
- builtins.object
-
- Graph
-
- BipartiteGraph
-
- CompleteBipartiteGraph
- CompleteGraph
- CycleGraph
- DualGraph
- EmptyGraph
- GridGraph
-
- SnakeGraph
- IntervalIntersectionsGraph
-
- RandomIntervalIntersectionsGraph
- IsingModel
- LineGraph
- MISModel
- MetropolisChain
- PermutationGraph
-
- RandomPermutationGraph
- Q_Coloring
- RandomFixedDegreeSequenceGraph
- RandomFixedSizeGraph
- RandomGraph
- RandomRegularGraph
- RandomValuationGraph
- TreeGraph
-
- RandomTree
-
- RandomSpanningForest
-
- BestDeterminedSpanningForest
- RandomSpanningTree
- TriangulatedGrid
class BestDeterminedSpanningForest(RandomSpanningForest) |
| |
BestDeterminedSpanningForest(g, seed=None, Debug=False)
Constructing the most determined spanning tree (or forest if not connected)
using Kruskal's greedy algorithm on the dual valuation.
Example Python session:
>>> from graphs import *
>>> g = RandomValuationGraph(seed=2)
>>> g.showShort()
*---- short description of the graph ----*
Name : 'randomGraph'
Vertices : ['v1', 'v2', 'v3', 'v4', 'v5']
Valuation domain : {'med': Decimal('0'), 'min': Decimal('-1'), 'max': Decimal('1')}
Gamma function :
v1 -> ['v2', 'v3']
v2 -> ['v4', 'v1', 'v5', 'v3']
v3 -> ['v1', 'v5', 'v2']
v4 -> ['v5', 'v2']
v5 -> ['v4', 'v2', 'v3']
>>> mt = BestDeterminedSpanningForest(g)
>>> mt.exportGraphViz('spanningTree',WithSpanningTree=True)
*---- exporting a dot file for GraphViz tools ---------*
Exporting to spanningTree.dot
[['v4', 'v2', 'v1', 'v3', 'v1', 'v2', 'v5', 'v2', 'v4']]
neato -Tpng spanningTree.dot -o spanningTree.png
.. image:: spanningTree.png
:alt: Colored bes determined panning tree
:width: 300 px
:align: center |
| |
- Method resolution order:
- BestDeterminedSpanningForest
- RandomSpanningForest
- RandomTree
- TreeGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, g, seed=None, Debug=False)
- Constructor for Graph objects.
- __repr__(self)
- Show method for best determined spanning forests instances.
Methods inherited from RandomSpanningForest:
- computeAverageTreeDetermination(self, dfs=None)
- Renders the mean average determinations of the spanning trees.
Methods inherited from TreeGraph:
- computeTreeCenters(self)
- Renders the centre(s) of the tree, i.e. the vertices with minimal maximal neighbourhood depths.
- exportOrientedTreeGraphViz(self, root=None, direction='downward', fileName=None, graphType='png', graphSize='7,7', fontSize=10, Comments=True)
- Graphviz drawing of the rooted and oriented tree.
When *root* == *None*, the first in alphabetic order of the tree centre(s) is chosen. If *direction* = 'best', the tree grows downwards, otherwise it grows upwards.
- tree2OrientedTree(self, root=None, Debug=False)
- Converts a TreeGraph object into a rooted and oriented tree digraph.
When *root* == *None*, the first in alphabetic order of the tree centre(s) is chosen.
- tree2Pruefer(self, vertices=None, Debug=False)
- Renders the Pruefer code of a given tree.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class BipartiteGraph(Graph) |
| |
Abstract root class for bipartite graph instances |
| |
- Method resolution order:
- BipartiteGraph
- Graph
- builtins.object
Methods defined here:
- __init__()
- Abstract class entry
- __repr__(self)
- Default description for bipartite graph instances.
- computeBestDeterminedMaximalMatching(self, Comments=True, Debug=True)
- Using the ranked pairs rule for assembling a best determined maximal matching
- exportGraphViz(self, fileName=None, Comments=True, graphType='png', graphSize='7,7', edgeColor='blue', bgcolor='cornsilk', lineWidth=1, Debug=True)
- Exports GraphViz dot file for bipartite graph drawing filtering.
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class CompleteBipartiteGraph(BipartiteGraph) |
| |
CompleteBipartiteGraph(verticesKeysA, verticesKeysB, Debug=True)
Instances of complete bipartite graphs bipolarly valuated in {-1,0,+1}.
Each vertex x in part *A* is positively linked to each vertex y in part *B*,
i.e edges[frozenset({x,y})] = +1 for all *x* in part *A* and all *y* in part *B*.
*Parameter*:
* *verticesKeysA* is the list of vertex keys of part *A*
* *verticesKeysB* is the list of vertex keys of part *B* |
| |
- Method resolution order:
- CompleteBipartiteGraph
- BipartiteGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, verticesKeysA, verticesKeysB, Debug=True)
- Abstract class entry
Methods inherited from BipartiteGraph:
- __repr__(self)
- Default description for bipartite graph instances.
- computeBestDeterminedMaximalMatching(self, Comments=True, Debug=True)
- Using the ranked pairs rule for assembling a best determined maximal matching
- exportGraphViz(self, fileName=None, Comments=True, graphType='png', graphSize='7,7', edgeColor='blue', bgcolor='cornsilk', lineWidth=1, Debug=True)
- Exports GraphViz dot file for bipartite graph drawing filtering.
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class CompleteGraph(Graph) |
| |
CompleteGraph(order=5, verticesKeys=None, verticesIdPrefix='v', seed=None)
Instances of complete graphs bipolarly valuated in {-1,0,+1}.
Each vertex x is positively linked to
all the other vertices (edges[frozenset({x,y})] = +1)
*Parameter*:
* *order* (positive integer)
* *verticesKeys* is a list of vertex keys. When given, the *order*
and the *verticesIdPrefix* parameters are ignored and
the order is the length of the given list. |
| |
- Method resolution order:
- CompleteGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, order=5, verticesKeys=None, verticesIdPrefix='v', seed=None)
- Constructor for Graph objects.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class CycleGraph(Graph) |
| |
CycleGraph(order=5, seed=None, Debug=False)
Instances of cycle graph characterized in [-1,1].
*Parameter*:
* order (positive integer)
Example of 7-cycle graph instance:
.. image:: 7cycle.png
:alt: 7-cycle instance
:width: 300 px
:align: center |
| |
- Method resolution order:
- CycleGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, order=5, seed=None, Debug=False)
- Constructor for Graph objects.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class DualGraph(Graph) |
| |
DualGraph(other)
Instantiates the dual Graph object of a given other Graph instance.
The relation constructor returns the dual of self.relation with formula:
relationOut[a][b] = Max - self.relation[a][b] + Min
where Max (resp. Min) equals valuation maximum (resp. minimum). |
| |
- Method resolution order:
- DualGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, other)
- Constructor for Graph objects.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class EmptyGraph(Graph) |
| |
EmptyGraph(order=5, seed=None)
Intantiates graph of given order without any positively valued edge.
*Parameter*:
* order (positive integer) |
| |
- Method resolution order:
- EmptyGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, order=5, seed=None)
- Constructor for Graph objects.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class Graph(builtins.object) |
| |
Graph(fileName=None, Empty=False, numberOfVertices=7, edgeProbability=0.5)
In the `graphs` module, the root :py:class:`graphs.Graph` class provides a generic graph model. A given object consists in:
1. a vertices dictionary
2. a characteristic valuation domain, {-1,0,+1} by default
3. an edges dictionary, characterising each edge in the given valuation domain
4. a gamma function dictionary, holding the neighborhood vertices of each vertex
General structure::
vertices = {'v1': {'name': ...,'shortName': ...},
'v2': {'name': ...,'shortName': ...},
'v3': {'name': ...,'shortName': ...},
... }
valuationDomain = {'min': -1, 'med': 0, 'max': 1}
edges = {frozenset({'v1','v2'}): 1,
frozenset({'v1','v3'}): 1,
frozenset({'v2','v3'}): -1,
...}
## links from each vertex to its neighbors
gamma = {'v1': {'v2',v3'}, 'v2': {'v1'}, 'v3': {'v1'}, ... }
Example python3 session:
>>> from graphs import Graph
>>> g = Graph(numberOfVertices=5,edgeProbability=0.5) # random instance
>>> g.showShort()
*----- show short --------------*
*---- short description of the graph ----*
Name : 'random'
Vertices : ['v1', 'v2', 'v3', 'v4', 'v5']
Valuation domain : {'med': 0, 'max': 1, 'min': -1}
Gamma function :
v1 -> ['v4']
v2 -> []
v3 -> ['v4']
v4 -> ['v1', 'v3']
v5 -> [] |
| |
Methods defined here:
- __init__(self, fileName=None, Empty=False, numberOfVertices=7, edgeProbability=0.5)
- Constructor for Graph objects.
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class GridGraph(Graph) |
| |
GridGraph(n=5, m=5, valuationMin=-1, valuationMax=1)
Specialization of the general Graph class for generating
temporary Grid graphs of dimension n times m.
*Parameters*:
* n,m > 0
* valuationDomain ={'min':-1, 'med':0, 'max':+1}
Default instantiation (5 times 5 Grid Digraph):
* n = 5,
* m=5,
* valuationDomain = {'min':-1.0,'max':1.0}.
Example of 5x5 GridGraph instance:
.. image:: grid-5-5.png
:alt: 5x5 grid instance
:width: 300 px
:align: center |
| |
- Method resolution order:
- GridGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, n=5, m=5, valuationMin=-1, valuationMax=1)
- Constructor for Graph objects.
- showShort(self)
- Generic show method for Graph instances.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class IntervalIntersectionsGraph(Graph) |
| |
IntervalIntersectionsGraph(intervals, Debug=False)
Inveral graph constructed from a list of *n*
intervals, ie pairs (a,b) of integer numbers where a < b. |
| |
- Method resolution order:
- IntervalIntersectionsGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, intervals, Debug=False)
- Constructor for Graph objects.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class IsingModel(Graph) |
| |
IsingModel(g, beta=0, nSim=None, Debug=False)
Specialisation of a Gibbs Sampler for the Ising model
Example:
>>> from graphs import GridGraph, IsingModel
>>> g = GridGraph(n=15,m=15)
>>> g.showShort()
*----- show short --------------*
Grid graph : grid-15-15
n : 15
m : 15
order : 225
size : 420
>>> im = IsingModel(g,beta=0.3,nSim=100000,Debug=False)
Running a Gibbs Sampler for 100000 step !
>>> im.exportGraphViz(colors=['lightblue','lightcoral'])
*---- exporting a dot file for GraphViz tools ---------*
Exporting to grid-15-15-ising.dot
fdp -Tpng grid-15-15-ising.dot -o grid-15-15-ising.png
.. image:: grid-15-15-ising.png
:alt: ising configuration of a 15x15 grid with beta=0.3
:width: 300 px
:align: center |
| |
- Method resolution order:
- IsingModel
- Graph
- builtins.object
Methods defined here:
- __init__(self, g, beta=0, nSim=None, Debug=False)
- Constructor for Graph objects.
- computeSpinEnergy(self)
- Spin energy H(c) of a spin configuration is
H(c) = -sum_{{x,y} in self.edges}[spin_c(x)*spin_c(y)]
- exportGraphViz(self, fileName=None, Comments=True, graphType='png', graphSize='7,7', edgeColor='black', bgcolor='cornsilk', colors=['gold', 'lightblue'])
- Exports GraphViz dot file for Ising models drawing filtering.
- generateSpinConfiguration(self, beta=0, nSim=None, Debug=False)
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class LineGraph(Graph) |
| |
LineGraph(graph)
Line graphs represent the **adjacencies between edges** of a graph instance.
Iterated line graph constructions are usually expanding, except for chordless cycles,
where the same cycle is repeated. And, for non-closed paths (interupted cycles), where iterated line graphs
progressively reduce one by one the number of vertices and edges and become eventually an empty graph.
>>> g = CycleGraph(order=5)
>>> g
*------- Graph instance description ------*
Instance class : CycleGraph
Instance name : cycleGraph
Graph Order : 5
Graph Size : 5
Valuation domain : [-1.00; 1.00]
Attributes : ['name', 'order', 'vertices', 'valuationDomain',
'edges', 'size', 'gamma']
g.showShort()
*---- short description of the graph ----*
Name : 'cycleGraph'
Vertices : ['v1', 'v2', 'v3', 'v4', 'v5']
Valuation domain : {'min': Decimal('-1'), 'med': Decimal('0'), 'max': Decimal('1')}
Gamma function :
v1 -> ['v2', 'v5']
v2 -> ['v1', 'v3']
v3 -> ['v2', 'v4']
v4 -> ['v3', 'v5']
v5 -> ['v4', 'v1']
degrees : [0, 1, 2, 3, 4]
distribution : [0, 0, 5, 0, 0]
nbh depths : [0, 1, 2, 3, 4, 'inf.']
distribution : [0, 0, 5, 0, 0, 0]
# the line graph of the 5-cycle graph
>>> lg = LineGraph(g)
>>> lg
*------- Graph instance description ------*
Instance class : LineGraph
Instance name : line-cycleGraph
Graph Order : 5
Graph Size : 5
Valuation domain : [-1.00; 1.00]
Attributes : ['name', 'graph', 'valuationDomain', 'vertices',
'order', 'edges', 'size', 'gamma']
>>> lg.showShort()
*---- short description of the graph ----*
Name : 'line-cycleGraph'
Vertices : [frozenset({'v2', 'v1'}), frozenset({'v1', 'v5'}), frozenset({'v2', 'v3'}),
frozenset({'v4', 'v3'}), frozenset({'v4', 'v5'})]
Valuation domain : {'min': Decimal('-1'), 'med': Decimal('0'), 'max': Decimal('1')}
Gamma function :
frozenset({'v2', 'v1'}) -> [frozenset({'v2', 'v3'}), frozenset({'v1', 'v5'})]
frozenset({'v1', 'v5'}) -> [frozenset({'v2', 'v1'}), frozenset({'v4', 'v5'})]
frozenset({'v2', 'v3'}) -> [frozenset({'v2', 'v1'}), frozenset({'v4', 'v3'})]
frozenset({'v4', 'v3'}) -> [frozenset({'v2', 'v3'}), frozenset({'v4', 'v5'})]
frozenset({'v4', 'v5'}) -> [frozenset({'v4', 'v3'}), frozenset({'v1', 'v5'})]
degrees : [0, 1, 2, 3, 4]
distribution : [0, 0, 5, 0, 0]
nbh depths : [0, 1, 2, 3, 4, 'inf.']
distribution : [0, 0, 5, 0, 0, 0]
MISs in line graphs provide maximal matchings - maximal sets of independent edges - in the original graph.
>>> c8 = CycleGraph(order=8)
>>> lc8 = LineGraph(c8)
>>> lc8.showMIS()
*--- Maximal Independent Sets ---*
[frozenset({'v3', 'v4'}), frozenset({'v5', 'v6'}), frozenset({'v1', 'v8'})]
[frozenset({'v2', 'v3'}), frozenset({'v5', 'v6'}), frozenset({'v1', 'v8'})]
[frozenset({'v8', 'v7'}), frozenset({'v2', 'v3'}), frozenset({'v5', 'v6'})]
[frozenset({'v8', 'v7'}), frozenset({'v2', 'v3'}), frozenset({'v4', 'v5'})]
[frozenset({'v7', 'v6'}), frozenset({'v3', 'v4'}), frozenset({'v1', 'v8'})]
[frozenset({'v2', 'v1'}), frozenset({'v8', 'v7'}), frozenset({'v4', 'v5'})]
[frozenset({'v2', 'v1'}), frozenset({'v7', 'v6'}), frozenset({'v4', 'v5'})]
[frozenset({'v2', 'v1'}), frozenset({'v7', 'v6'}), frozenset({'v3', 'v4'})]
[frozenset({'v7', 'v6'}), frozenset({'v2', 'v3'}), frozenset({'v1', 'v8'}), frozenset({'v4', 'v5'})]
[frozenset({'v2', 'v1'}), frozenset({'v8', 'v7'}), frozenset({'v3', 'v4'}), frozenset({'v5', 'v6'})]
number of solutions: 10
cardinality distribution
card.: [0, 1, 2, 3, 4, 5, 6, 7, 8]
freq.: [0, 0, 0, 8, 2, 0, 0, 0, 0]
execution time: 0.00029 sec.
The two last MISs of cardinality 4 (see Lines 14-15 above) give
**isomorphic perfect maximum matchings** of the 8-cycle graph.
Every vertex of the cycle is adjacent to a matching edge.
Odd cyle graphs do not admid any perfect matching.
>>> maxMatching = c8.computeMaximumMatching()
>>> c8.exportGraphViz(fileName='maxMatchingcycleGraph',
... matching=maxMatching)
*---- exporting a dot file for GraphViz tools ---------*
Exporting to maxMatchingcyleGraph.dot
Matching: {frozenset({'v1', 'v2'}), frozenset({'v5', 'v6'}),
frozenset({'v3', 'v4'}), frozenset({'v7', 'v8'}) }
circo -Tpng maxMatchingcyleGraph.dot -o maxMatchingcyleGraph.png
.. image:: maxMatchingcycleGraph.png
:alt: maximum matching colored c8
:width: 300 px
:align: center |
| |
- Method resolution order:
- LineGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, graph)
- Constructor for Graph objects.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class MISModel(Graph) |
| |
MISModel(g, nSim=None, maxIter=20, seed=None, Debug=False)
Specialisation of a Gibbs Sampler for the hard code model,
that is a random MIS generator.
Example:
>>> from graphs import MISModel
>>> from digraphs import CirculantDigraph
>>> dg = CirculantDigraph(order=15)
>>> g = dg.digraph2Graph()
>>> g.showShort()
*---- short description of the graph ----*
Name : 'c15'
Vertices : ['1', '10', '11', '12', '13', '14',
'15', '2', '3', '4', '5', '6', '7',
'8', '9']
Valuation domain : {'med': 0, 'min': -1, 'max': 1}
Gamma function :
1 -> ['2', '15']
10 -> ['11', '9']
11 -> ['10', '12']
12 -> ['13', '11']
13 -> ['12', '14']
14 -> ['15', '13']
15 -> ['1', '14']
2 -> ['1', '3']
3 -> ['2', '4']
4 -> ['3', '5']
5 -> ['6', '4']
6 -> ['7', '5']
7 -> ['6', '8']
8 -> ['7', '9']
9 -> ['10', '8']
>>> mis = MISModel(g)
Running a Gibbs Sampler for 1050 step !
>>> mis.checkMIS()
{'2','4','7','9','11','13','15'} is maximal !
>>> mis.exportGraphViz()
*---- exporting a dot file for GraphViz tools ---------*
Exporting to c15-mis.dot
fdp -Tpng c15-mis.dot -o c15-mis.png
.. image:: c15-mis.png
:alt: 15-cycle with colored MIS
:width: 300 px
:align: center |
| |
- Method resolution order:
- MISModel
- Graph
- builtins.object
Methods defined here:
- __init__(self, g, nSim=None, maxIter=20, seed=None, Debug=False)
- Constructor for Graph objects.
- checkMIS(self, Comments=True)
- Verify maximality of independent set.
.. note::
Returns three sets: an independent choice,
the covered vertices, and the remaining uncovered vertices.
When the last set is empty, the independent choice is maximal.
- exportGraphViz(self, fileName=None, Comments=True, graphType='png', graphSize='7,7', misColor='lightblue', bgcolor='cornsilk')
- Exports GraphViz dot file for MIS models drawing filtering.
- generateMIS(self, Reset=True, nSim=None, seed=None, Comments=True, Debug=False)
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class MetropolisChain(Graph) |
| |
MetropolisChain(g, probs=None)
Specialisation of the graph class for implementing a generic
Metropolis Markov Chain Monte Carlo sampler with a given probability distribution
probs = {'v1': x, 'v2': y, ...}
Usage example:
>>> from graphs import *
>>> g = Graph(numberOfVertices=5,edgeProbability=0.5)
>>> g.showShort()
*---- short description of the graph ----*
Name : 'randomGraph'
Vertices : ['v1', 'v2', 'v3', 'v4', 'v5']
Valuation domain : {'max': 1, 'med': 0, 'min': -1}
Gamma function :
v1 -> ['v2', 'v3', 'v4']
v2 -> ['v1', 'v4']
v3 -> ['v5', 'v1']
v4 -> ['v2', 'v5', 'v1']
v5 -> ['v3', 'v4']
>>> probs = {}
>>> n = g.order
>>> i = 0
>>> verticesList = [x for x in g.vertices]
>>> verticesList.sort()
>>> for v in verticesList:
... probs[v] = (n - i)/(n*(n+1)/2)
... i += 1
>>> met = MetropolisChain(g,probs)
>>> frequency = met.checkSampling(verticesList[0],nSim=30000)
>>> for v in verticesList:
... print(v,probs[v],frequency[v])
v1 0.3333 0.3343
v2 0.2666 0.2680
v3 0.2 0.2030
v4 0.1333 0.1311
v5 0.0666 0.0635
>>> met.showTransitionMatrix()
* ---- Transition Matrix -----
Pij | 'v1' 'v2' 'v3' 'v4' 'v5'
-----|-------------------------------------
'v1' | 0.23 0.33 0.30 0.13 0.00
'v2' | 0.42 0.42 0.00 0.17 0.00
'v3' | 0.50 0.00 0.33 0.00 0.17
'v4' | 0.33 0.33 0.00 0.08 0.25
'v5' | 0.00 0.00 0.50 0.50 0.00 |
| |
- Method resolution order:
- MetropolisChain
- Graph
- builtins.object
Methods defined here:
- MCMCtransition(self, si, Debug=False)
- __init__(self, g, probs=None)
- Constructor for Graph objects.
- checkSampling(self, si, nSim)
- computeTransitionMatrix(self)
- saveCSVTransition(self, fileName='transition', Debug=False)
- Persistent storage of the transition matrix in the form of
a csv file.
- showTransitionMatrix(self, Sorted=True, IntegerValues=False, vertices=None, relation=None, ndigits=2, ReflexiveTerms=True)
- Prints on stdout the transition probabilities in
vertices X vertices table format.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class PermutationGraph(Graph) |
| |
PermutationGraph(permutation=[4, 3, 6, 1, 5, 2], Debug=False)
Martin Ch. Gulombic, Agorithmic Graph Theory and Perfect Graphs 2nd Ed.,
Annals of Discrete Mathematics 57, Elsevier, Chapter 7, pp 157-170.
>>> from graphs import PermutationGraph
>>> g = PermutationGraph()
>>> g
*------- Graph instance description ------*
Instance class : PermutationGraph
Instance name : permutationGraph
Graph Order : 6
Permutation : [4, 3, 6, 1, 5, 2]
Graph Size : 9
Valuation domain : [-1.00; 1.00]
Attributes : ['name', 'vertices', 'order', 'permutation',
'valuationDomain', 'edges', 'size', 'gamma']
>>> g.exportGraphViz()
*---- exporting a dot file for GraphViz tools ---------*
Exporting to permutationGraph.dot
fdp -Tpng permutationGraph.dot -o permutationGraph.png
.. image:: permutationGraph.png
:alt: Default permutation graph
:width: 300 px
:align: center |
| |
- Method resolution order:
- PermutationGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, permutation=[4, 3, 6, 1, 5, 2], Debug=False)
- Constructor for Graph objects.
- computeMinimalVertexColoring(self, colors=None, Comments=False, Debug=False)
- Computes a vertex coloring by using a minimal number of color queues for sorting the
given permutation. Sets by the way the chromatic number of the graph.
- transitiveOrientation(self)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
This orientation is always transitive and delivers a weak ordering of the vertices.
>>> from graphs import PermutationGraph
>>> g = PermutationGraph()
>>> dg = g.transitiveOrientation()
>>> dg
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : oriented_permutationGraph
Digraph Order : 6
Digraph Size : 9
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name', 'order', 'actions', 'valuationdomain',
'relation', 'gamma', 'notGamma', 'size']
>>> dg.exportGraphViz()
*---- exporting a dot file for GraphViz tools ---------*
Exporting to oriented_permutationGraph.dot
0 { rank = same; 1; 2; }
1 { rank = same; 5; 3; }
2 { rank = same; 4; 6; }
dot -Grankdir=TB -Tpng oriented_permutationGraph.dot -o oriented_permutationGraph.png
.. image:: oriented_permutationGraph.png
:alt: Transitive orientation of a permutation graph
:width: 200 px
:align: center
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class Q_Coloring(Graph) |
| |
Q_Coloring(g, colors=['gold', 'lightcoral', 'lightblue'], nSim=None, maxIter=20, seed=None, Comments=True, Debug=False)
Generate a q-coloring of a Graph instance via a Gibbs MCMC sampler in
nSim simulation steps (default = len(graph.edges)).
Example 3-coloring of a grid 6x6 :
>>> from graphs import *
>>> g = GridGraph(n=6,m=6)
>>> g.showShort()
*----- show short --------------*
Grid graph : grid-6-6
n : 6
m : 6
order : 36
size : 60
>>> g.exportGraphViz()
*---- exporting a dot file for GraphViz tools ---------*
Exporting to grid-6-6.dot
neato -Tpng grid-6-6.dot -o grid-6-6.png
>>> qc = Q_Coloring(g,colors=['gold','lightblue','lightcoral'])
Iteration: 1
Running a Gibbs Sampler for 1260 step !
The q-coloring with 3 colors is feasible !!
>>> qc.exportGraphViz()
*---- exporting a dot file for GraphViz tools ---------*
Exporting to grid-6-6-qcoloring.dot
fdp -Tpng grid-6-6-qcoloring.dot -o grid-6-6-qcoloring.png
.. image:: grid-6-6-qcoloring.png
:alt: 3 coloring of a 6x6 grid
:width: 300 px
:align: center |
| |
- Method resolution order:
- Q_Coloring
- Graph
- builtins.object
Methods defined here:
- __init__(self, g, colors=['gold', 'lightcoral', 'lightblue'], nSim=None, maxIter=20, seed=None, Comments=True, Debug=False)
- Constructor for Graph objects.
- checkFeasibility(self, Comments=True, Debug=False)
- exportGraphViz(self, fileName=None, Comments=True, graphType='png', graphSize='7,7', bgcolor='cornsilk', layout=None)
- Exports GraphViz dot file for q-coloring drawing filtering.
The graph drawing layout is depending on the graph type, but can be forced to either
'fdp', 'circo' or 'neato' with the layout parameter.
Example:
>>> g = Graph(numberOfVertices=10,edgeProbability=0.4)
>>> g.showShort()
*---- short description of the graph ----*
Name : 'randomGraph'
Vertices : ['v1','v10','v2','v3','v4','v5','v6','v7','v8','v9']
Valuation domain : {'max': 1, 'min': -1, 'med': 0}
Gamma function :
v1 -> ['v7', 'v2', 'v3', 'v5']
v10 -> ['v4']
v2 -> ['v1', 'v7', 'v8']
v3 -> ['v1', 'v7', 'v9']
v4 -> ['v5', 'v10']
v5 -> ['v6', 'v7', 'v1', 'v8', 'v4']
v6 -> ['v5', 'v8']
v7 -> ['v1', 'v5', 'v8', 'v2', 'v3']
v8 -> ['v6', 'v7', 'v2', 'v5']
v9 -> ['v3']
>>> qc = Q_Coloring(g,nSim=1000)
Running a Gibbs Sampler for 1000 step !
>>> qc.checkFeasibility()
The q-coloring with 3 colors is feasible !!
>>> qc.exportGraphViz()
*---- exporting a dot file for GraphViz tools ---------*
Exporting to randomGraph-qcoloring.dot
fdp -Tpng randomGraph-qcoloring.dot -o randomGraph-qcoloring.png
.. image:: randomGraph-qcoloring.png
:alt: 3-coloring of a random graph
:width: 300 px
:align: center
- generateFeasibleConfiguration(self, Reset=True, nSim=None, seed=None, Debug=False)
- showConfiguration(self)
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class RandomFixedDegreeSequenceGraph(Graph) |
| |
RandomFixedDegreeSequenceGraph(order=7, degreeSequence=[3, 3, 2, 2, 1, 1, 0], seed=None)
Specialization of the general Graph class for generating
temporary random graphs with a fixed sequence of degrees.
.. warning::
The implementation is not guaranteeing a uniform choice
among all potential valid graph instances. |
| |
- Method resolution order:
- RandomFixedDegreeSequenceGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, order=7, degreeSequence=[3, 3, 2, 2, 1, 1, 0], seed=None)
- Constructor for Graph objects.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class RandomFixedSizeGraph(Graph) |
| |
RandomFixedSizeGraph(order=7, size=14, seed=None, Debug=False)
Generates a random graph with a fixed size (number of edges), by instantiating a fixed numbers of arcs
from random choices in the set of potential pairs of vertices numbered from 1 to order. |
| |
- Method resolution order:
- RandomFixedSizeGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, order=7, size=14, seed=None, Debug=False)
- Constructor for Graph objects.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class RandomGraph(Graph) |
| |
RandomGraph(order=5, edgeProbability=0.4, seed=None)
Random instances of the Graph class
*Parameters*:
* order (positive integer)
* edgeProbability (in [0,1]) |
| |
- Method resolution order:
- RandomGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, order=5, edgeProbability=0.4, seed=None)
- Constructor for Graph objects.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class RandomIntervalIntersectionsGraph(IntervalIntersectionsGraph) |
| |
RandomIntervalIntersectionsGraph(order=5, seed=None, m=0, M=10, Debug=False)
Random generator for IntervalIntersectionsGraph intances. |
| |
- Method resolution order:
- RandomIntervalIntersectionsGraph
- IntervalIntersectionsGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, order=5, seed=None, m=0, M=10, Debug=False)
- Constructor for Graph objects.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class RandomPermutationGraph(PermutationGraph) |
| |
RandomPermutationGraph(order=6, seed=None)
A generator for random permutation graphs. |
| |
- Method resolution order:
- RandomPermutationGraph
- PermutationGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, order=6, seed=None)
- Constructor for Graph objects.
Methods inherited from PermutationGraph:
- computeMinimalVertexColoring(self, colors=None, Comments=False, Debug=False)
- Computes a vertex coloring by using a minimal number of color queues for sorting the
given permutation. Sets by the way the chromatic number of the graph.
- transitiveOrientation(self)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
This orientation is always transitive and delivers a weak ordering of the vertices.
>>> from graphs import PermutationGraph
>>> g = PermutationGraph()
>>> dg = g.transitiveOrientation()
>>> dg
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : oriented_permutationGraph
Digraph Order : 6
Digraph Size : 9
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name', 'order', 'actions', 'valuationdomain',
'relation', 'gamma', 'notGamma', 'size']
>>> dg.exportGraphViz()
*---- exporting a dot file for GraphViz tools ---------*
Exporting to oriented_permutationGraph.dot
0 { rank = same; 1; 2; }
1 { rank = same; 5; 3; }
2 { rank = same; 4; 6; }
dot -Grankdir=TB -Tpng oriented_permutationGraph.dot -o oriented_permutationGraph.png
.. image:: oriented_permutationGraph.png
:alt: Transitive orientation of a permutation graph
:width: 200 px
:align: center
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class RandomRegularGraph(Graph) |
| |
RandomRegularGraph(order=7, degree=2, seed=None)
Specialization of the general Graph class for generating
temporary random regular graphs of fixed degrees. |
| |
- Method resolution order:
- RandomRegularGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, order=7, degree=2, seed=None)
- Constructor for Graph objects.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class RandomSpanningForest(RandomTree) |
| |
RandomSpanningForest(g, seed=None, Debug=False)
Random instance of a spanning forest (one or more trees)
generated from a random depth first search graph g traversal.
.. image:: spanningForest.png
:alt: randomSpanningForest instance
:width: 300 px
:align: center |
| |
- Method resolution order:
- RandomSpanningForest
- RandomTree
- TreeGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, g, seed=None, Debug=False)
- Constructor for Graph objects.
- computeAverageTreeDetermination(self, dfs=None)
- Renders the mean average determinations of the spanning trees.
Methods inherited from RandomTree:
- __repr__(self)
- Show method for RandomTree instances.
Methods inherited from TreeGraph:
- computeTreeCenters(self)
- Renders the centre(s) of the tree, i.e. the vertices with minimal maximal neighbourhood depths.
- exportOrientedTreeGraphViz(self, root=None, direction='downward', fileName=None, graphType='png', graphSize='7,7', fontSize=10, Comments=True)
- Graphviz drawing of the rooted and oriented tree.
When *root* == *None*, the first in alphabetic order of the tree centre(s) is chosen. If *direction* = 'best', the tree grows downwards, otherwise it grows upwards.
- tree2OrientedTree(self, root=None, Debug=False)
- Converts a TreeGraph object into a rooted and oriented tree digraph.
When *root* == *None*, the first in alphabetic order of the tree centre(s) is chosen.
- tree2Pruefer(self, vertices=None, Debug=False)
- Renders the Pruefer code of a given tree.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class RandomSpanningTree(RandomTree) |
| |
RandomSpanningTree(g, seed=None, Debug=False)
Uniform random instance of a spanning tree
generated with Wilson's algorithm from a connected Graph g instance.
.. Note::
Wilson's algorithm only works for connecte graphs.
.. image:: randomSpanningTree.png
:alt: randomSpanningTree instance
:width: 300 px
:align: center |
| |
- Method resolution order:
- RandomSpanningTree
- RandomTree
- TreeGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, g, seed=None, Debug=False)
- Constructor for Graph objects.
Methods inherited from RandomTree:
- __repr__(self)
- Show method for RandomTree instances.
Methods inherited from TreeGraph:
- computeTreeCenters(self)
- Renders the centre(s) of the tree, i.e. the vertices with minimal maximal neighbourhood depths.
- exportOrientedTreeGraphViz(self, root=None, direction='downward', fileName=None, graphType='png', graphSize='7,7', fontSize=10, Comments=True)
- Graphviz drawing of the rooted and oriented tree.
When *root* == *None*, the first in alphabetic order of the tree centre(s) is chosen. If *direction* = 'best', the tree grows downwards, otherwise it grows upwards.
- tree2OrientedTree(self, root=None, Debug=False)
- Converts a TreeGraph object into a rooted and oriented tree digraph.
When *root* == *None*, the first in alphabetic order of the tree centre(s) is chosen.
- tree2Pruefer(self, vertices=None, Debug=False)
- Renders the Pruefer code of a given tree.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class RandomTree(TreeGraph) |
| |
RandomTree(order=None, vertices=None, prueferCode=None, seed=None, Debug=False)
Instance of a tree generated from a random Prüfer code.
.. image:: randomTree.png
:alt: radomTree instance
:width: 300 px
:align: center |
| |
- Method resolution order:
- RandomTree
- TreeGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, order=None, vertices=None, prueferCode=None, seed=None, Debug=False)
- Constructor for Graph objects.
- __repr__(self)
- Show method for RandomTree instances.
Methods inherited from TreeGraph:
- computeTreeCenters(self)
- Renders the centre(s) of the tree, i.e. the vertices with minimal maximal neighbourhood depths.
- exportOrientedTreeGraphViz(self, root=None, direction='downward', fileName=None, graphType='png', graphSize='7,7', fontSize=10, Comments=True)
- Graphviz drawing of the rooted and oriented tree.
When *root* == *None*, the first in alphabetic order of the tree centre(s) is chosen. If *direction* = 'best', the tree grows downwards, otherwise it grows upwards.
- tree2OrientedTree(self, root=None, Debug=False)
- Converts a TreeGraph object into a rooted and oriented tree digraph.
When *root* == *None*, the first in alphabetic order of the tree centre(s) is chosen.
- tree2Pruefer(self, vertices=None, Debug=False)
- Renders the Pruefer code of a given tree.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class RandomValuationGraph(Graph) |
| |
RandomValuationGraph(order=5, ndigits=2, seed=None)
Specialization of the genuine Graph class for generating temporary
randomly valuated graphs in the range [-1.0;1.0].
*Parameter*:
* order (positive integer)
* ndigits (decimal precision) |
| |
- Method resolution order:
- RandomValuationGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, order=5, ndigits=2, seed=None)
- Constructor for Graph objects.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class SnakeGraph(GridGraph) |
| |
SnakeGraph(p, q)
Snake graphs S(p/q) are made up of all the integer grid squares between
the lower and upper Christofel paths of the rational number p/q,
where p and q are two coprime integers such that
0 <= p <= q, i.e. p/q gives an irreducible ratio between 0 and 1.
*Reference*: M. Aigner,
Markov's Theorem and 100 Years of the Uniqueness Conjecture, Springer, 2013, p. 141-149
S(4/7) snake graph instance::
>>> from graphs import SnakeGraph
>>> s4_7 = SnakeGraph(p=4,q=7)
>>> s4_7.showShort()
*---- short description of the snake graph ----*
Name : 'snakeGraph'
Rational p/q : 4/7
Christoffel words:
Upper word : BBABABA
Lower word : ABABABB
>>> s4_7.exportGraphViz('4_7_snake',lineWidth=3,arcColor='red')
.. image:: 4_7_snake.png
:alt: 4/7 snake graph instance
:width: 300 px
:align: center |
| |
- Method resolution order:
- SnakeGraph
- GridGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, p, q)
- Constructor for Graph objects.
- __repr__(self)
- Show method for SnakeGraph instances.
- showShort(self, WithVertices=False)
- Show method for SnakeGraph instances.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class TreeGraph(Graph) |
| |
TreeGraph(graph)
Tree graphs generated from a given Prüfer code |
| |
- Method resolution order:
- TreeGraph
- Graph
- builtins.object
Methods defined here:
- __init__(self, graph)
- Constructor for Graph objects.
- __repr__(self)
- Show method for Tree instances.
- computeTreeCenters(self)
- Renders the centre(s) of the tree, i.e. the vertices with minimal maximal neighbourhood depths.
- exportOrientedTreeGraphViz(self, root=None, direction='downward', fileName=None, graphType='png', graphSize='7,7', fontSize=10, Comments=True)
- Graphviz drawing of the rooted and oriented tree.
When *root* == *None*, the first in alphabetic order of the tree centre(s) is chosen. If *direction* = 'best', the tree grows downwards, otherwise it grows upwards.
- tree2OrientedTree(self, root=None, Debug=False)
- Converts a TreeGraph object into a rooted and oriented tree digraph.
When *root* == *None*, the first in alphabetic order of the tree centre(s) is chosen.
- tree2Pruefer(self, vertices=None, Debug=False)
- Renders the Pruefer code of a given tree.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
- showShort(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class TriangulatedGrid(Graph) |
| |
TriangulatedGrid(n=5, m=5, valuationMin=-1, valuationMax=1)
Specialization of the general Graph class for generating
temporary triangulated grids of dimension n times m.
*Parameters*:
* n,m > 0
* valuationDomain = {'min':m, 'max':M}
Example of 5x5 triangulated grid instance:
.. image:: triangular-5-5.png
:alt: triangulated 5x5 grid
:width: 300 px
:align: center |
| |
- Method resolution order:
- TriangulatedGrid
- Graph
- builtins.object
Methods defined here:
- __init__(self, n=5, m=5, valuationMin=-1, valuationMax=1)
- Constructor for Graph objects.
- showShort(self)
- Generic show method for Graph instances.
Methods inherited from Graph:
- __neg__(self)
- Make the negation operator -self available for Graph instances.
Returns a DualGraph instance of self.
- __repr__(self)
- Default presentation method for Graph instances.
- breadthFirstSearch(self, s, alphabeticOrder=True, Warnings=True, Debug=False)
- Breadth first search through a graph in lexicographical order
of the vertex keys.
Renders a list of vertice keys in
increasing distance from the origin *s*. Ties in the distances
are resolved by alphabetic ordering of the vertice keys.
A warning is issued when the graph is not connected and the resulting
search does not cover the whole set of graph vertices.
Source: Cormen, Leiserson, Rivest & Stein, *Introduction to Algorithms* 2d Ed., MIT Press 2001.
- computeChordlessCycles(self, Cycle3=False, Comments=False, Debug=False)
- Renders the set of all chordless cycles observed in a Graph
intance. Inspired from Dias, Castonguay, Longo & Jradi,
Algorithmica 2015.
.. note::
By default, a chordless cycle must have at least length 4.If the Cycle3 flag is set to True,
the cyclicly closed triplets will be inserted as 3-cycles in the result.
- computeCliques(self, Comments=False)
- Computes all cliques, ie maximal complete subgraphs in self:
.. Note::
- Computes the maximal independent vertex sets in the dual of self.
- Result is stored in self.cliques.
- computeComponents(self)
- Computes the connected components of a graph instance.
Returns a partition of the vertices as a list
- computeDegreeDistribution(self, Comments=False)
- Renders the distribution of vertex degrees.
- computeDiameter(self, Oriented=False)
- Renders the diameter (maximal neighbourhood depth) of the digraph instance.
.. Note::
The diameter of a disconnected graph is considered to be *infinite*
(results in a value -1) !
- computeGirth(self, girthType='any', Comments=False)
- Renders the *girth* of self, i.e. the length of the shortest chordless cycle in the graph.
*Parameter*:
* *girthType* = "any" (default) | "odd" | "even"
- computeGraphCentres(self)
- Renders the vertices of minimal Neighborhood depth.
- computeMIS(self, Comments=False)
- Prints all maximal independent vertex sets:
.. Note::
- Result is stored in self.misset !
- computeMaximumMatching(self, Comments=False)
- Renders a maximum matching in *self* by computing
a maximum MIS of the line graph of *self*.
- computeNeighbourhoodDepth(self, vertex, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeNeighbourhoodDepthDistribution(self, Comments=False, Debug=False)
- Renders the distribtion of neighbourhood depths.
- computeOrientedDigraph(self, PartiallyDetermined=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the adjacent vertices' numbers.
If self is a PermutationGraph instance, the orientation will be transitive.
The parameter *PartiallyDetermined*: {True|False by default], converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,seed=101)
>>> dg = g.computeOrientedDigraph()
>>> dg
*------- Digraph instance description ------*
Instance class : Digraph
Instance name : oriented_randomGraph
Digraph Order : 6
Digraph Size : 5
Valuation domain : [-1.00; 1.00]
Determinateness : 100.000
Attributes : ['name','order','actions','valuationdomain',
'relation', 'gamma', 'notGamma',
'size', 'transitivityDegree']
>>> dg.transitivityDegree
Decimal('0.7142857142857142857142857143')
- computePermutation(self, seq1=None, seq2=None, Comments=True)
- Tests whether the graph instance *self* is a permutation graph
and renders, in case the test is positive,
the corresponding permutation.
- computeSize(self)
- Renders the number of positively characterised edges of this graph instance
(result is stored in self.size).
- computeTransitivelyOrientedDigraph(self, PartiallyDetermined=False, Debug=False)
- Renders a digraph where each edge of the permutation graph *self*
is converted into an arc oriented in increasing order of the ranks of implication classes
detected with the :py:func:`digraphs.Digraph.isComparabilityGraph` test and stored in self.edgeOrientations.
The parameter *PartiallyDetermined*: {True|False (by default), converts if *True* all absent
edges of the graph into indeterminate symmetric relations in the resulting digraph.
Verifies if the graph instance is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
>>> from graphs import RandomGraph
>>> g = RandomGraph(order=6,edgeProbability=0.5,seed=100)
>>> og = g.computeTransitivelyOrientedDigraph()
>>> if og is not None:
... print(og)
... print('Transitivity degree: %.3f' % og.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveDigraph
Instance name : trans_oriented_randomGraph
Digraph Order : 6
Digraph Size : 7
Valuation domain : [-1.00 - 1.00]
Determinateness : 46.667
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Transitivity degree: 1.000
>>> gd = -g
>>> ogd = gd.computeTransitivelyOrientedDigraph()
>>> if ogd is not None:
... print(ogd)
... print('Dual transitivity degree: %.3f' % ogd.transitivityDegree)
*------- Digraph instance description ------*
Instance class : TransitiveOrder
Instance name : trans_oriented_dual_randomGraph
Digraph Order : 6
Digraph Size : 8
Valuation domain : [-1.00 - 1.00]
Determinateness : 53.333
Attributes : ['name', 'order', 'actions',
'valuationdomain', 'relation',
'gamma', 'notGamma', 'size',
'transitivityDegree']
Dual transitivity degree: 1.000
- depthFirstSearch(self, Debug=False)
- Depth first search through a graph in lexicographical order
of the vertex keys.
- exportEdgeOrientationsGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', layout=None, arcColor='black', lineWidth=1, palette=1, bgcolor='cornsilk', Debug=False)
- Exports GraphViz dot file for oriented graph drawing filtering.
Example:
>>> from graphs import *
>>> g = RandomGraph(order=6,seed=100)
>>> if g.isComparabilityGraph():
... g.exportEdgeOrientationsGraphViz('orientedGraph')
.. image:: orientedGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportGraphViz(self, fileName=None, verticesSubset=None, Comments=True, graphType='png', graphSize='7,7', WithSpanningTree=False, WithVertexColoring=False, matching=None, layout=None, arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for graph drawing filtering.
Example:
>>> g = Graph(numberOfVertices=5,edgeProbability=0.3)
>>> g.exportGraphViz('randomGraph')
.. image:: randomGraph.png
:alt: Random graph
:width: 300 px
:align: center
- exportPermutationGraphViz(self, fileName=None, permutation=None, Comments=True, WithEdgeColoring=True, hspace=100, vspace=70, graphType='png', graphSize='7,7', arcColor='black', bgcolor='cornsilk', lineWidth=1)
- Exports GraphViz dot file for permutation drawing filtering.
Horizontal (default=100) and vertical (default=75) spaces betwen the vertices'
positions may be explicitely given in *hspace* and *vspace* parameters.
.. note::
If no *permutation* is provided, it is supposed to exist a self.permutation attribute.
- gammaSets(self, Debug=False)
- renders the gamma function as dictionary
- generateIndependent(self, U)
- Generator for all independent vertices sets
with neighborhoods of a graph instance:
.. note::
* Initiate with U = self._singletons().
* Yields [independent set, covered set, all vertices - covered set)].
* If independent set == (all vertices - covered set), the given independent set is maximal !
- graph2Digraph(self)
- Converts a Graph object into a symmetric Digraph object.
- isComparabilityGraph(self, Debug=False)
- Verifies if the graph instance is a comparability graph.
If yes, a tranditive orientation of the edges is stored
in self.edgeOrientations.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 129-132.
- isConnected(self)
- Cheks if self is a connected graph instance.
- isIntervalGraph(self, Comments=False)
- Checks whether the graph self is triangulated and
its dual is a comparability graph.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isPerfectGraph(self, Comments=False, Debug=False)
- A graph *g* is perfect when neither *g*, nor *-g*, contain any chordless
cycle of odd length.
- isPermutationGraph(self, Comments=False)
- Checks whether the graph self and
its dual are comparability graphs.
*Source*: M. Ch. Golumbic (2004) Algorithmic Graph Thery and Perfect Graphs,
Annals of Discrete Mathematics 57, Elsevier, p. 16.
- isSplitGraph(self, Comments=False)
- Checks whether the graph ' *self* ' and its dual ' *-self* ' are
triangulated graphs
- isTree(self)
- Checks if self is a tree by verifing the required number of
edges: order-1; and the existence of leaves.
- isTriangulated(self)
- Checks if a graph contains no chordless cycle of
length greater or equal to 4.
- randomDepthFirstSearch(self, seed=None, Debug=False)
- Depth first search through a graph in random order of the vertex keys.
.. Note::
The resulting spanning tree (or forest) is by far not uniformly selected
among all possible trees. Spanning stars will indeed be much less
probably selected then streight walks !
- recodeValuation(self, newMin=-1, newMax=1, ndigits=2, Debug=False)
- Recodes the characteristic valuation domain according
to the parameters given.
.. note::
Default values gives a normalized valuation domain
- save(self, fileName='tempGraph', Debug=False)
- Persistent storage of a Graph class instance in the form of a python source code file.
- setEdgeValue(self, edge, value, Comments=False)
- Wrapper for updating the characteristic valuation of a Graph instance.
The egde parameter consists in a pair of vertices;
edge = ('v1','v2') for instance.
The new value must be in the limits of the valuation domain.
- showCliques(self)
- showEdgesCharacteristicValues(self, ndigits=2)
- Prints the edge links of the bipartite graph instance
- showMIS(self)
- showMore(self)
- Generic show method for Graph instances.
Data descriptors inherited from Graph:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |