tulip
module API¶
Utility functions¶
Graph management¶
- tlp.newGraph()
Creates and returns a new empty graph.
- Return type
- tlp.loadGraph(filename, graph=None)
Loads a graph in the TLP format from a file (extension can be .tlp, .tlp.gz, or .tlpz). Returns the graph (a new graph if none is provided) or
None
if the import fails.- Parameters
filename (string) – the path to the tlp file
graph – if provided, import new graph elements in that already existing graph
- Return type
- tlp.loadGraph(fileName)
Loads a graph serialized in a file through one the available Tulip import plugins based on its extension.
Since Tulip 4.8, the selection of the import plugin is based on the provided filename extension. The import will fail if the selected import plugin is not loaded. The graph file formats that can currently be imported are: TLP (.tlp, .tlp.gz, .tlpz), TLP Binary (.tlpb, .tlpb.gz, .tlpbz), TLP JSON (.json), Gephi (.gexf), Pajek (.net, .paj), GML (.gml), Graphviz (.dot) and UCINET (.txt).
Before Tulip 4.8 and as a fallback, this function uses the “TLP Import” import plugin (always loaded as it is linked into the tulip-core library).
Returns a new graph or
None
if the import fails.- Parameters
filename (string) – the path to the file in one of the supported formats to parse.
- Return type
- tlp.saveGraph(graph, filename)
Serializes the corresponding graph and all its subgraphs (depending on the format) to a file through the available Tulip export plugins.
Since Tulip 4.8, the selection of the export plugin is based on the provided filename extension. The export will fail if the selected export plugin is not loaded. The file formats the graph can be exported to are: TLP (.tlp, .tlp.gz, .tlpz), TLP Binary (.tlpb, .tlpb.gz, .tlpbz), TLP JSON (.json), GML (.gml), CSV (.csv), SVG (.svg, .svgz)
Before Tulip 4.8 and as a fallback, this function uses the “TLP Export” export plugin (always loaded as it is linked into the tulip-core library).
Returns whether the export was successful or not.
- Parameters
graph (
tlp.Graph
) – the graph to exportfilename (string) – the path to the destination file
- Return type
boolean
- tlp.saveGraph(graph)
New in version 4.5.
Saves a graph to the same file from which it has been loaded (if the output format is supported). Returns
True
if the graph has been successfully saved.- Parameters
graph (
tlp.Graph
) – the graph to export- Return type
boolean
- Throws
an exception if there is no file attached to the graph
- tlp.importGraph(importPluginName, params={})
Imports a graph using a Tulip import plugin. Returns a new graph or None if the import fails.
- Parameters
importPluginName (string) – the name of the Tulip import plugin
params (a dictionary with string keys (parameters names) and parameters values) – The parameters to the algorithm.
newGraph (
tlp.Graph
) – if provided, add imported graph elements in that graph
- Return type
- Throws
an exception if the requested import plugin is not registered in the plugins database.
- tlp.exportGraph(exportPluginName, graph, outputFilePath, params={})
Exports a graph to a file using a Tulip export plugin.
- Parameters
graph (
tlp.Graph
) – the graph to exportoutputFilePath (string) – the path of the file the export plugin will write to
exportPluginName (string) – the name of the Tulip export plugin to execute
params (a dictionary with string keys (parameters names) and parameters values) – The parameters to the algorithm.
- Return type
boolean
- Throws
an exception if the requested export plugin is not registered in the plugins database.
- tlp.copyToGraph(outGraph, inGraph, inSelection=None, outSelection=None)
Appends the selected part of a graph (properties, nodes and edges) into another one. If no selection is done, the whole input graph graph is appended. The output selection is used to select the appended nodes & edges
- Parameters
outGraph (
tlp.Graph
) – the graph on which to append elementsinGraph (
tlp.Graph
) – the graph to appendinSelection (
tlp.BooleanProperty
) – boolean property attached to inGraph, only selected elements will be appended if providedoutSelection (
tlp.BooleanProperty
) – boolean property attached to outGraph, appended nodes and edges will be selected if provided
Warning
The input selection is extended to all selected edge ends.
- tlp.removeFromGraph(inGraph, inSelection=None)
Removes the selected part of a graph (properties values, nodes and edges). If no selection is done, the whole graph is reset to default value.
- Parameters
inGraph (
tlp.Graph
) – the graph on which to remove elementsinSelection (
tlp.BooleanProperty
) – boolean property attached to inGraph, only selected elements will be removed if provided
Warning
The selection is extended to all selected edge ends.
- tlp.getRootGraphs()
Returns an iterator on all the currently existing root graphs.
- Return type
a Tulip iterator on
tlp.Graph
objects
Graph measures and functions¶
- tlp.averagePathLength(graph)
Returns the average path length of a graph, that is the sum of the shortest distances for all pair of distinct nodes in that graph divided by the number of those pairs. For a pair of non connected nodes, the shorted distance is set to 0.
- Parameters
graph (
tlp.Graph
) – the graph on which to compute the average path length- Return type
float
- tlp.averageClusteringCoefficient(graph)
Returns the clustering coefficient of a graph as the average of the local clustering coefficients (see
tlp.clusteringCoefficient()
) of all the nodes.- Parameters
graph (
tlp.Graph
) – the graph on which to compute the average clustering coefficient- Return type
float
- tlp.clusteringCoefficient(graph, result, maxDepth=1)
Assigns to each node its local clustering coefficient that is the proportion of edges between the nodes within its neighbourhood divided by the number of edges that could possibly exist between them. This quantifies how close its neighbors are to being a clique.
- Parameters
graph (
tlp.Graph
) – the graph on which to compute the clustering coefficient for each noderesult (
tlp.DoubleProperty
) – a graph property in which the results will be storedmaxDepth (integer) – Deprecated. This parameter is not used anymore.
- tlp.dagLevel(graph, result)
Assigns to each node of a Directed Acyclic Graph a level such that if the edge e(u,v) exists level(u) < level(v). The algorithm ensures that the number of level used is minimal.
- Parameters
graph (
tlp.Graph
) – the graph on which to compute the dag levelresult (
tlp.IntegerProperty
) – a graph property in which the results will be stored
Warning
The graph must be acyclic (no self loops).
- tlp.minDegree(graph)
Returns the minimum degree of the graph’s nodes.
- Parameters
graph (
tlp.Graph
) – the graph on which to compute the minimum degree- Return type
integer
- tlp.maxDegree(graph)
Returns the maximum degree of the graph’s nodes.
- Parameters
graph (
tlp.Graph
) – the graph on which to compute the maximum degree- Return type
integer
- tlp.maxDistance(graph, node, result, direction)¶
Computes the distances from a node to all the other nodes of a graph and return the maximum one.
- Parameters
graph (
tlp.Graph
) – the graph on which to compute the maximum distancenode (
tlp.node
) – an existing graph noderesult (
tlp.IntegerProperty
) – a graph property in which the results will be storeddirection (tlp.EDGE_TYPE.DIRECTED, tlp.EDGE_TYPE.INV_DIRECTED, tlp.EDGE_TYPE.UNDIRECTED) – specify if the graph must be directed or not
- Return type
integer
- Throws
an exception if the node does not belong to the graph
- tlp.maxDistanceWeighted(graph, node, result, weight, direction)¶
Computes the distances from a node to all the other nodes of a weighted graph and return the maximum one.
- Parameters
graph (
tlp.Graph
) – the graph on which to compute the maximum distancenode (
tlp.node
) – an existing graph noderesult (
tlp.DoubleProperty
) – a graph property in which the results will be storedresult – a graph property in which edges lengths are stored
direction (tlp.EDGE_TYPE.DIRECTED, tlp.EDGE_TYPE.INV_DIRECTED, tlp.EDGE_TYPE.UNDIRECTED) – specify if the graph must be directed or not
- Return type
double
- Throws
an exception if the node does not belong to the graph
- tlp.reachableNodes(graph, startNode, maxDistance, direction)¶
Returns the nodes that can be reached from a node, according to a direction, at distance less or equal to a maximum one.
- Parameters
- Return type
set of
tlp.node
- Throws
an exception if the node does not belong to the graph
- tlp.bfs(graph)
New in version 5.0.
Performs a breadth-first search on a graph and returns a list containing the nodes of the graph in the order they have been visited.
- tlp.bfs(graph, root)
New in version 4.2.
Performs a breadth-first search on a graph and returns a list containing the nodes of the graph in the order they have been visited.
- tlp.dfs(graph)
New in version 5.0.
Performs a depth-first search on a graph and returns a list containing the nodes of the graph in the order they have been visited.
- tlp.dfs(graph, root)
New in version 4.2.
Performs a depth-first search on a graph and returns a list containing the nodes of the graph in the order they have been visited.
- tlp.selectShortestPaths(graph, src, tgt, pathType, weights, selection)¶
Select the shortest paths between two nodes. Returns
True
if a path exists between the src and tgt nodes.One usage would be:
tlp.selectShortestPaths(graph, tlp.node(1), tlp.node(2), tlp.ShortestPathType.AllPaths, graph['viewMetric'], graph['viewSelection'])
Then the existing shortest paths will correspond to the edges (and connected nodes) of graph for which
graph['viewSelection']
value is equal toTrue
.- Parameters
graph (
tlp.Graph
) – The graph to compute on.src (
tlp.node
) – The source node of the pathstgt (
tlp.node
) – The target node of the pathspathType (
tlp.ShortestPathType.OnePath
,tlp.ShortestPathType.OneDirectedPath
,tlp.ShortestPathType.OneReversedPath
,tlp.ShortestPathType.AllPaths
,tlp.ShortestPathType.AllDirectedPaths
,tlp.ShortestPathType.AllReversedPaths
) – The type of path to consider (Reversed
is the same thanDirected
from target node to source node)weights (
tlp.DoubleProperty
) – A graph property giving the edges weight if weighted paths have to be considered. Can be set to null to select unweighted paths.selection (
tlp.BooleanProperty
) – The graph property for which the values corresponding to the nodes/edges owning to the shortests path(s) will be set to True.
- Return type
boolean
- Throws
an exception if one of the source or target nodes does not belong to the graph.
Geometry¶
- tlp.computeBoundingBox(graph, selection=None)
New in version 3.8.
Computes the bounding box of a graph according to nodes positions and edges bends defined in the default layout property “viewLayout”, nodes z-rotations defined in the default double property “viewRotation” and sizes of elements defined in the default size property “viewSize”.
- Parameters
graph (
tlp.Graph
) – the graph on which to compute its bounding boxselection (
tlp.BooleanProperty
) – a Boolean property to restrain the computation of the bounding box to selected elements (if provided)
- Return type
- Throws
an exception if the provided Boolean property is not attached to the graph
- tlp.computeBoundingBox(graph, layout, size, rotation, selection=None)
Computes the bounding box of a graph according to nodes positions, edges bends, nodes z-rotations and sizes of elements.
- Parameters
graph (
tlp.Graph
) – the graph on which to compute its bounding boxlayout (
tlp.LayoutProperty
) – a layout property containing positions of the graph elementssize (
tlp.SizeProperty
) – a size property containing the sizes of the graph elements.rotation (
tlp.DoubleProperty
) – a double property containing the z-rotations of nodesselection (
tlp.BooleanProperty
) – a Boolean property to restrain the computation of the bounding box to selected elements (if provided)
- Return type
- Throws
an exception if the provided properties are not attached to the graph
- tlp.computeBoundingRadius(graph, selection=None)
New in version 3.8.
Computes a bounding sphere (or a bounding circle if the graph has a 2D layout) of a graph according to nodes positions and edges bends defined in the default layout property “viewLayout”, nodes z-rotations defined in the default double property “viewRotation” and sizes of elements defined in the default size property “viewSize”.
Returns a tuple of
tlp.Coord
whose first member is the center of the bounding sphere (circle for 2D layout) and second member is the farthest point from the center (computed from graph elements positions). To get the bounding radius, you have to compute the distance between the two members of the tuple (use thetlp.Vec3f.dist()
method).- Parameters
graph (
tlp.Graph
) – the graph on which to compute its bounding sphereselection (
tlp.BooleanProperty
) – a Boolean property to restrain the computation of the bounding sphere to selected elements (if provided)
- Return type
- Throws
an exception if the provided Boolean property is not attached to the graph
- tlp.computeBoundingRadius(graph, layout, size, rotation, selection=None)
Computes a bounding sphere (or a bounding circle if the graph has a 2D layout) of a graph according to node position edge bends node z-rotation, and size of elements.
Returns a tuple of
tlp.Coord
whose first member is the center of the bounding sphere (circle for 2D layout) and second member is the farthest point from the center (computed from graph elements positions). To get the bounding radius, you have to compute the distance between the two members of the tuple (use thetlp.Vec3f.dist()
method).- Parameters
graph (
tlp.Graph
) – the graph on which to compute its bounding spherelayout (
tlp.LayoutProperty
) – a layout property containing positions of the graph elementssize (
tlp.SizeProperty
) – a size property containing the sizes of the graph elements.rotation (
tlp.DoubleProperty
) – a double property containing the z-rotations of nodesselection (
tlp.BooleanProperty
) – a Boolean property to restrain the computation of the bounding sphere to selected elements (if provided)
- Return type
- Throws
an exception if the provided properties are not attached to the graph
- tlp.computeConvexHull(points)
New in version 3.8.
Computes a convex hull of a set of points. Only works with 2D layouts. Returns a list of
tlp.Coord
containing the vertices of the points convex hull correctly ordered.- Parameters
points (:list of class:tlp.Coord) – the points on which to compute a conbex hull
- Return type
list of
tlp.Coord
- tlp.computeConvexHull(graph, selection=None)
New in version 3.8.
Computes a convex hull of a graph according to nodes positions and edges bends defined in the default layout property “viewLayout”, nodes z-rotations defined in the default double property “viewRotation” and sizes of elements defined in the default size property “viewSize”. Only works with 2D layouts. Returns a list of
tlp.Coord
containing the vertices of the graph convex hull correctly ordered.- Parameters
graph (
tlp.Graph
) – the graph on which to compute its convex hullselection (
tlp.booleanProperty
) – a Boolean property to restrain the computation of the convex hull to selected elements (if provided)
- Return type
list of
tlp.Coord
- Throws
an exception if the provided Boolean property is not attached to the graph
- tlp.computeConvexHull(graph, layout, size, rotation, selection=None)
Computes a convex hull of a graph according to nodes positions, edges bends, nodes z-rotations, and sizes of elements. Only works with 2D layouts. Returns a list of
tlp.Coord
containing the vertices of the graph convex hull correctly ordered.- Parameters
graph (
tlp.Graph
) – the graph on which to compute its convex hulllayout (
tlp.LayoutProperty
) – a layout property containing positions of the graph elementssize (
tlp.SizeProperty
) – a size property containing the sizes of the graph elements.rotation (
tlp.DoubleProperty
) – a double property containing the z-rotations of nodesselection (
tlp.BooleanProperty
) – a Boolean property to restrain the computation of the convex hull to selected elements (if provided)
- Return type
list of
tlp.Coord
- Throws
an exception if the provided properties are not attached to the graph
- tlp.convexHull2D(points)
New in version 4.2.
Computes the 2D convex hull of a list of points (the z-coordinate is not taken into account) using the Qhull library. Returns a list of indexes in the list of points defining the hull polygon in counterclockwise order.
- Parameters
points (list of
tlp.Coord
) – the points on which to compute the 2D convex hull- Return type
list of integers
- tlp.convexHull(points)
New in version 4.2.
Computes the 2D/3D convex hull of a list of points using the Qhull library. Returns a tuple whose first member is the list of facets defining the convex hull (segments for 2D, triangles for 3D) and second member is the list of neighbors facets for each facet. A facet is defined by a list of indexes in the list of points. The ith element of the neighbors list is a list of indexes in the facets list corresponding to the neighbors facets of the ith facet.
- Parameters
points (list of
tlp.Coord
) – the points on which to compute the 2D/3D convex hull- Return type
(list of list of integers, list of list of integers)
- tlp.computeLinesIntersection(line1, line2)
New in version 3.8.
Computes the intersection point (if any) of two 3D lines. Returns a tuple whose first member is a Boolean indicating if the lines intersect (if
False
it means that lines are parallel or skew) and second member is the intersection point (if any).
- tlp.computePolygonCentroid(points)
New in version 3.8.
Computes the centroid of a polygon.
- tlp.delaunayTriangulation(points)
New in version 3.8.
Computes the delaunay triangulation of a set of points and returns the set of delaunay edges and simplices (triangles in 2d, tetrahedra in 3d). Returns a tuple whose first member is the list of edges and second member is the list of simplices, or
None
if the triangulation failed. Edges and simplices are defined using indexes into the original list of points.- Parameters
points (list of
tlp.Coord
) – a list of points on which to compute a delaunay triangulation- Return type
(list of (integer, integer), list of integer) or
None
- class tlp.VoronoiDiagram¶
New in version 3.8.
That class defines a voronoi diagram. Use the
tlp.voronoiDiagram()
function to get an instance of it.- cell(cellIdx)¶
Returns the ith voronoi cell. A cell is defined by a list of indexes in the voronoi vertices.
- Parameters
cellIdx (integer) – the index of the cell to return
- Return type
set of integer
- degreeOfVertex(vertexIdx)¶
Returns the degree (number of incident edges) of the ith voronoi vertex
- Parameters
vertexIdx (integer) – the index of the vertex on which to return the degree
- Return type
integer
- edge(edgeIdx)¶
Returns the ith voronoi edge. An edge is defined by two indexes in the voronoi vertices.
- Parameters
edgeIdx (integer) – the index of the edge to return
- Return type
(integer, integer)
- nbEdges()¶
Returns the number of voronoi edges.
- Return type
integer
- nbSites()¶
Returns the number of voronoi sites.
- Return type
integer
- nbVertices()¶
Returns the number of voronoi vertices.
- Return type
integer
- site(siteIdx)¶
Returns the ith voronoi site.
- Parameters
siteIdx (integer) – the index of the site to return
- Return type
- vertex(vertexIdx)¶
Returns the ith voronoi vertex.
- Parameters
vertexIdx (integer) – the index of the vertex to return
- Return type
- voronoiCellForSite(siteIdx)¶
Returns the cell associated to the ith site.
- Parameters
siteIdx (integer) – the index of the site on which to return the cell
- Return type
set of integer
- voronoiEdgesForSite(siteIdx)¶
Returns the voronoi edges surrounding the ith site.
- Parameters
siteIdx (integer) – the index of the site on which to return edges
- Return type
list of (integer, integer)
- tlp.voronoiDiagram(sites)
New in version 3.8.
Computes the voronoi diagram of a set of sites (for 2D and 3D layouts). It automatically computes the set of all voronoi vertices, edges and cells. In order to not have to deal with infinite voronoi rays, the input layout is enclosed in its convex hull in 2d or in its bounding box in 3d. It enables to have a connected voronoi cell for each input site.
- Parameters
sites (list of
tlp.Coord
) – the sites from which to compute the voronoi diagram- Return type
Parametric curves computation¶
- tlp.computeBezierPoint(controlPoints, t)
Computes the position of the point at t (0 <= t <= 1) along a Bezier curve defined by a set of control points.
- tlp.computeBezierPoints(controlPoints, nbCurvePoints=100)
Computes a set of points approximating a Bezier curve.
- tlp.computeCatmullRomPoint(controlPoints, t, closedCurve=False, alpha=0.5)
Computes the position of the point at t (0 <= t <= 1) along a Catmull-Rom curve defined by a set of control points. The features of this type of spline are the following :
the spline passes through all of the control points
the spline is C1 continuous, meaning that there are no discontinuities in the tangent direction and magnitude
the spline is not C2 continuous. The second derivative is linearly interpolated within each segment, causing the curvature to vary linearly over the length of the segment
- Parameters
controlPoints (list of
tlp.Coord
) – the control points of the Catmull Rom curvet (float) – the curve parameter
closedCurve (boolean) – if
True
, the curve will be closed, meaning a Bezier segment will connect the last and first control pointalpha (float) – curve parameterization parameter (0 <= alpha <= 1), alpha = 0 -> uniform parameterization, alpha = 0.5 -> centripetal parameterization, alpha = 1.0 -> chord-length parameterization
- Return type
- tlp.computeCatmullRomPoints(controlPoints, closedCurve=False, nbCurvePoints=100, alpha=0.5)
Computes a set of points approximating a Catmull-Rom curve.
- Parameters
controlPoints (list of
tlp.Coord
) – the control points of the Catmull Rom curveclosedCurve (boolean) – if
True
, the curve will be closed, meaning a Bezier segment will connect the last and first control pointnbCurvePoints (integer) – the number of curve points to compute
alpha (floatts to compute) – curve parameterization parameter (0 <= alpha <= 1), alpha = 0 -> uniform parameterization, alpha = 0.5 -> centripetal parameterization, alpha = 1.0 -> chord-length parameterization
- Return type
list of
tlp.Coord
- tlp.computeOpenUniformBsplinePoint(controlPoints, t, curveDegree=3)
Computes the position of the point at t (0 <= t <= 1) along an open uniform B-spline curve defined by a set of control points. An uniform B-spline is a piecewise collection of Bezier curves of the same degree, connected end to end. The features of this type of spline are the following :
the spline is C^2 continuous, meaning there is no discontinuities in curvature
the spline has local control : its parameters only affect a small part of the entire spline
A B-spline is qualified as open when it passes through its first and last control points.
- tlp.computeOpenUniformBsplinePoints(controlPoints, curveDegree=3, nbCurvePoints=100)
Computes a set of points approximating an open uniform B-spline curve.
Plugins Management¶
- tlp.getTulipRelease()
Returns the current version number of Tulip in the form X.Y.Z, X being the major version, Y the minor version, and Z the patch version.
- Return type
string
- tlp.initTulipLib()
Looks for the Tulip plugins directory and fills the Tulip path variables : tlp.TulipLibDir, tlp.TulipPluginsPath, tlp.TulipBitmapDir. The plug-ins directory can be defined in different ways, given by order of prevalence:
the TLP_DIR environment variable, if it has a value
the appDirPath parameter, if it is not NULL
at that point, the Tulip paths will be retrieved from the path of the loaded Tulip shared library (you must dispose of a standard Tulip installation for that feature to work, meaning the relative path for the Tulip plugins folder to the Tulip libraries one must be ../lib/tulip/).
a fallback value of ‘C:/Tulip/lib/’ on windows, or ‘/usr/local/lib/’ on Unix.
- tlp.loadPlugins()
Loads C++ plugins installed in the directories listed in the tlp.TulipPluginsPath variable (in the form “<path1>;<path2>” on windows and “<path1>:<path2>” on unix). The tlp.TulipPluginsPath can be initialized with standard Tulip directories by calling the
tlp.initTulipLib()
function.
- tlp.loadPluginsFromDir(pluginsDir)
New in version 4.2.
Loads C++ and Python plugins installed in a specific directory.
Since Tulip 4.8, the loading of plugins is done recursively, each subdirectory will be visited to search for plugins to load.
- Parameters
pluginsDir (string) – the root directory path to recursively search for python files (file extension: .py) or shared libraries containing the Tulip plugin (file extension : .so on linux, .dylib on mac, .dll on windows)
- tlp.loadPlugin(filename)
Loads a C++ plugin or a Python plugin from a specific file (shared library or Python source file). Returns
True
if the plugin was correctly loaded.- Parameters
filename (string) – the path to the the python file (file extension: .py) or shared library containing the Tulip plugin (file extension : .so on linux, .dylib on mac, .dll on windows)
- Return type
boolean
- tlp.loadPluginsCheckDependencies()
Checks the dependencies of all C++ plugins loaded so far. If a plugin does not have all its dependencies fulfilled, it is unloaded and removed from the current plugins database.
- tlp.getDefaultPluginParameters(pluginName, graph=None)
Returns a Python dictionary with string keys filled with default parameters (if any) for a given plugin (algorithm, import, property algorithm, …).
- Parameters
pluginName (string) – the name of the plugin on which to retrieve its default parameters
graph (
tlp.Graph
) – if provided, property parameters will be retrieved from the graph if they exist
- Return type
dictionary with string keys (parameters names) and parameters values
- tlp.getImportPluginsList()
Returns a list containing the names of the import plugins (written in C++ or Python) loaded so far. Import plugins are objects implementing the tlp::ImportModule interface in C++ or the
tlp.ImportModule
interface in Python.- Return type
list of string
- tlp.getExportPluginsList()
Returns a list containing the names of the export plugins (written in C++ or Python) loaded so far. Export plugins are objects implementing the tlp::ExportModule interface in C++ or the
tlp.ExportModule
interface in Python.- Return type
list of string
- tlp.getAlgorithmPluginsList()
Returns a list containing the names of the algorithm plugins (written in C++ or Python) loaded so far. Algorithm plugins are objects implementing the tlp::Algorithm interface in C++ or the
tlp.Algorithm
interface in Python.- Return type
list of string
- tlp.getBooleanAlgorithmPluginsList()
Returns a list containing the names of the boolean algorithm plugins (written in C++ or Python) loaded so far. Boolean algorithm plugins are objects implementing the tlp::BooleanAlgorithm interface in C++ or the
tlp.BooleanAlgorithm
interface in Python.- Return type
list of string
- tlp.getColorAlgorithmPluginsList()
Returns a list containing the names of the color algorithm plugins (written in C++ or Python) loaded so far. Color algorithm plugins are objects implementing the tlp::ColorAlgorithm interface in C++ or the
tlp.ColorAlgorithm
interface in Python.- Return type
list of string
- tlp.getDoubleAlgorithmPluginsList()
Returns a list containing the names of the double algorithm plugins (written in C++ or Python) loaded so far. Double algorithm plugins are objects implementing the tlp::DoubleAlgorithm interface in C++ or the
tlp.DoubleAlgorithm
interface in Python.- Return type
list of string
- tlp.getIntegerAlgorithmPluginsList()
Returns a list containing the names of the integer algorithm plugins (written in C++ or Python) loaded so far. Integer algorithm plugins are objects implementing the tlp::IntegerAlgorithm interface in C++ or the
tlp.IntegerAlgorithm
interface in Python.- Return type
list of string
- tlp.getLayoutAlgorithmPluginsList()
Returns a list containing the names of the layout algorithm plugins (written in C++ or Python) loaded so far. Layout algorithm plugins are objects implementing the tlp::LayoutAlgorithm interface in C++ or the
tlp.LayoutAlgorithm
interface in Python.- Return type
list of string
- tlp.getSizeAlgorithmPluginsList()
Returns a list containing the names of the size algorithm plugins (written in C++ or Python) loaded so far. Size algorithm plugins are objects implementing the tlp::SizeAlgorithm interface in C++ or the
tlp.SizeAlgorithm
interface in Python.- Return type
list of string
- tlp.getStringAlgorithmPluginsList()
Returns a list containing the names of the string algorithm plugins (written in C++ or Python) loaded so far. String algorithm plugins are objects implementing the tlp::StringAlgorithm interface in C++ or the
tlp.StringAlgorithm
interface in Python.- Return type
list of string
Graph elements classes¶
tlp.node¶
- class tlp.node¶
An instance of this class represents a node of a Tulip graph. It encapsulates an integer identifier. Use specific methods in the
tlp.Graph
class to get references on such objects (for instancetlp.Graph.addNode()
,tlp.Graph.getNodes()
,tlp.Graph.getOutNodes()
). Node objects can be used as keys in a Python dictionary.The node identifier can be accessed through the id class member. If necessary, it is automatically converted to an integer value with the __int__ special method.
- isValid()¶
Returns
True
if the node is valid, i.e., it is an element of a graph.- Return type
boolean
tlp.edge¶
- class tlp.edge¶
An instance of this class represents an edge of a Tulip graph. It encapsulates an integer identifier. Use specific methods in the
tlp.Graph
class to get references on such objects (for instancetlp.Graph.addEdge()
,tlp.Graph.getEdges()
,tlp.Graph.getInEdges()
). Edge objects can be used as keys in a Python dictionary.The edge identifier can be accessed through the id class member. If necessary, it is automatically converted to an integer value with the __int__ special method.
- isValid()¶
Returns
True
if the edge is valid, i.e., it is an element of a graph.- Return type
Boolean
The tlp.Graph class¶
- class tlp.Graph¶
This is the main Tulip class. It enables to:
create a directed graph
create and manipulate a subgraphs hierarchy
get semantic iterators on graph elements
create and retrieve properties of different types to get/set data on the graph
This class can not be instanced directly. Use
tlp.newGraph()
to create a new empty graph.
Modification of the graph structure¶
- tlp.Graph.clear()
Remove all nodes, edges and subgraphs from the graph .
- tlp.Graph.addNode(propertiesValues=None)
Adds a new node in the graph and returns it. This node is also added in all the graph’s ancestors to maintain the subgraph relation between graphs. Since Tulip 5.0, it is also possible to set graph properties values for the newly added node through the use of a dictionary (see
tlp.Graph.setNodePropertiesValues()
for more details).- Parameters
propertiesValues (a dictionary) – an optional dictionary containing graph properties values for the newly added node
- Return type
- tlp.Graph.addNode(node)
Adds an existing node in the graph. This node is also added in all the graph ancestors to maintain the subgraph relation between graphs.
- Parameters
node (
tlp.node
) – an existing node to add to the graph- Throws
an exception if the node does not belong to the root graph
Warning
The node must be an element of the graph hierarchy, thus it must be an element of the root graph.
Warning
One can’t add an existing node to the root graph.
- tlp.Graph.addNodes(nbNodes)
New in version 3.7.
Adds new nodes in the graph and returns them in a list. The new nodes are also added in all the graph ancestors to maintain the subgraph relation between graphs.
- Parameters
nbNodes (integer) – the number of nodes to add in the graph
- Return type
list of
tlp.node
Warning
the addedNodes vector is cleared before adding nodes.
- tlp.Graph.addNodes(itNodes)
New in version 3.7.
Adds existing nodes in the graph. The nodes are also added in all the graph ancestors to maintain the subgraph relation between graphs.
- Parameters
itNodes (a Tulip iterator on
tlp.node
objects) – an iterator on nodes to add- Throws
an exception if one of the node to add is not an element of the root graph.
Warning
The added nodes must be elements of the graph hierarchy, thus they must be elements of the root graph.
Warning
One can’t add existing nodes to the root graph.
- tlp.Graph.addNodes(nodes)
New in version 4.5.
Adds existing nodes in the graph. The nodes are also added in all the graph ancestors to maintain the subgraph relation between graphs.
- Parameters
nodes (a list of
tlp.node
objects) – a list of nodes to add- Throws
an exception if one of the node to add is not an element of the root graph.
Warning
The added nodes must be elements of the graph hierarchy, thus they must be elements of the root graph.
Warning
One can’t add existing nodes to the root graph.
- tlp.Graph.delNode(node, deleteInAllGraphs=False)
Deletes a node in the graph. This node is also removed in all the subgraphs of the graph to maintain the subgraph relation between graphs.
- Parameters
node (
tlp.node
) – the node to deletedeleteInAllGraphs (boolean) – if
True
, remove the node in all the hierarchy of graphs
- Throws
an exception if the node does not belong to the graph
- tlp.Graph.delNodes(itNodes, deleteInAllGraphs=False)
New in version 3.7.
Deletes nodes in the graph. These nodes are also removed in the subgraphs hierarchy of the current graph to maintain the subgraph relation between graphs.
- Parameters
itNodes (a Tulip iterator on
tlp.node
objects) – an iterator on the nodes to adddeleteInAllGraphs (boolean) – if
True
, these nodes are deleted in the whole hierarchy of graphs.
- Throws
an exception if one of the node to delete is not an element of the graph.
- tlp.Graph.delNodes(nodes, deleteInAllGraphs=False)
New in version 4.5.
Deletes nodes in the graph. These nodes are also removed in the subgraphs hierarchy of the current graph to maintain the subgraph relation between graphs.
- Parameters
nodes (a list of
tlp.node
objects) – a list of nodes to adddeleteInAllGraphs (boolean) – if
True
, these nodes are deleted in the whole hierarchy of graphs.
- Throws
an exception if one of the node to delete is not an element of the graph.
- tlp.Graph.addEdge(src, tgt, propertiesValues=None)
Adds a new edge in the graph and returns it. This edge is also added in all the graph’s ancestors to maintain the subgraph relation between graphs. Since Tulip 5.0, it is also possible to set graph properties values for the newly added edge through the use of a dictionary (see
tlp.Graph.setEdgePropertiesValues()
for more details).- Parameters
- Return type
- Throws
an exception if the provided source or target node does not belong to the graph
- tlp.Graph.addEdge(edge)
Adds an existing edge in the graph. This edge is also added in all the graph’s ancestors to maintain the subgraph relation between graphs.
- Parameters
edge (
tlp.edge
) – an existing edge to add to the graph- Throws
an exception if the edge does not belong to the root graph of if the source and target node of the edge are not elements of the graph
Warning
The edge must be an element of the graph hierarchy, thus it must be an element of the root graph.
Warning
One can’t add an existing edge to the root graph.
- tlp.Graph.addEdges(edges)
New in version 3.7.
Adds new edges in the graph and returns them in a list. The new edges are also added in all the graph ancestors to maintain the subgraph relation between graphs.
- tlp.Graph.addEdges(itEdges)
New in version 3.7.
Adds existing edges in the graph. The edges are also added in all the graph ancestors to maintain the subgraph relation between graphs.
- Parameters
itEdges (a Tulip iterator on
tlp.edge
objects) – an iterator on the edges to add- Throws
an exception if one of the edge to add is not an element of the root graph or if one of the edge extremities is not an element of the graph.
Warning
The added edges must be elements of the graph hierarchy, thus they must be elements of the root graph.
- tlp.Graph.addEdges(list_edges)
New in version 4.5.
Adds existing edges in the graph. The edges are also added in all the graph ancestors to maintain the subgraph relation between graphs.
- Parameters
list_edges (a list of
tlp.edge
objects) – a list of edges to add- Throws
an exception if one of the edge to add is not an element of the root graph or if one of the edge extremities is not an element of the graph.
Warning
The added edges must be elements of the graph hierarchy, thus they must be elements of the root graph.
Warning
It is not possible to add existing edges to the root graph.
- tlp.Graph.delEdge(edge, deleteInAllGraphs=False)
Deletes an edge in the graph. This edge is also removed in all the subgraphs of the graph to maintain the subgraph relation between graphs. The ordering of edges is preserved.
- Parameters
edge (
tlp.edge
) – the edge to deletedeleteInAllGraphs (boolean) – if
True
, remove the edge in all the hierarchy of graphs
- Throws
an exception if the edge does not belong to the graph
- tlp.Graph.delEdges(itEdges, deleteInAllGraphs=False)
New in version 3.7.
Deletes edges in the graph. These edges are also removed in the subgraphs hierarchy of the current graph to maintain the subgraph relation between graphs. The ordering of the remaining edges is preserved.
- Parameters
itEdges (a Tulip iterator on
tlp.edge
objects) – an iterator on the edges to deletedeleteInAllGraphs – If
True
, the edges are deleted in the whole graph hierarchy.deleteInAllGraphs – Boolean
- Throws
an exception if one of the edge to delete is not an element of the graph
- tlp.Graph.delEdges(edges, deleteInAllGraphs=False)
New in version 4.5.
Deletes edges in the graph. These edges are also removed in the subgraphs hierarchy of the current graph to maintain the subgraph relation between graphs.
- Parameters
edges (a list of
tlp.edge
objects) – a list of edges to deletedeleteInAllGraphs (Boolean) – if
True
, these edges are deleted in the whole graph hierarchy.
- Throws
an exception if one of the edge to delete is not an element of the graph
- tlp.Graph.setEdgeOrder(node, edges)
Sets the order of the edges around a node. This operation ensures that adjacent edges of a node will be ordered as they are in the list of edges given in parameter.
- tlp.Graph.swapEdgeOrder(node, edge1, edge2)
Swaps two edges in the adjacency list of a node.
- tlp.Graph.setSource(edge, src)
Sets the source of an existing edge.
- tlp.Graph.setTarget(edge, tgt)
Sets the target of an existing edge.
- tlp.Graph.setEnds(edge, src, tgt)
Sets both the source and target of an existing edge.
- tlp.Graph.reverse(edge)
Reverses the direction of an edge, the source becomes the target and the target becomes the source.
- Parameters
edge (
tlp.edge
) – the edge on which to revert the direction.- Throws
an exception if the edge does not belong to the graph
Warning
The ordering is global to the entire graph hierarchy. Thus, by changing the ordering in a graph you change the ordering in the hierarchy.
Creation and Modification of the subgraph hierarchy¶
- tlp.Graph.addSubGraph(selection=None, name='unnamed')
Creates and returns a new subgraph. The elements of the new subgraph are those selected in the selection. If there is no selection an empty subgraph is returned.
- Parameters
selection (
tlp.BooleanProperty
) – a Boolean property whose selected elements will be added to the subgraphname (string) – The name of the newly created subgraph. Defaults to “unnamed”.
- Return type
- tlp.Graph.addSubGraph(name)
New in version 3.7.
Creates and returns a new named subgraph of this graph.
- Parameters
name (string) – The name of the newly created subgraph.
- Return type
- tlp.Graph.addCloneSubGraph(name='unnamed', addSibling=False, addSiblingProperties=False)
New in version 4.5.
Creates and returns a subgraph of this graph (or the parent of this graph) that contains all its elements.
- Parameters
name (string) – The name of the newly created subgraph. Defaults to “unnamed”.
addSibling (bool) – if true a sibling of this graph will be created; a subgraph of this graph if not. Defaults to false
addSiblingProperties (bool) – if true all the local properties of this graph will be copied into its clone sibling. Defaults to false
- Return type
- tlp.Graph.inducedSubGraph(nodes, parentSubGraph=None, name='unnamed')
New in version 5.0.
Creates and returns a new subgraph of the graph induced by a set of nodes. The subgraph contains all the nodes from the set and all the existing edges between two nodes in the set including self-loops.
- Parameters
- Return type
- tlp.Graph.inducedSubGraph(selection, parentSubGraph=None, name='unnamed')
New in version 4.10.
Creates and returns a new subgraph of the graph induced by a selection of nodes and edges. The subgraph contains all the nodes of the set induced by the selected nodes but also the source and target nodes from the selected edges and all the existing edges between two nodes in the set including self-loops.
- Parameters
selection (
tlp.BooleanProperty
) – a selection of nodes and edgesparentSubGraph (
tlp.Graph
) – If provided, is used as parent graph for the newly created subgraph instead of the graph this method is called on.name (string) – The name of the newly created subgraph
- Return type
- tlp.Graph.delSubGraph(subgraph)
Delete a subgraph of this graph. The subgraph’s subgraphs become subgraphs of the graph.
- Parameters
subgraph (
tlp.Graph
) – the subgraph to remove
- tlp.Graph.delAllSubGraphs(subgraph)
Delete a subgraph of this graph and all its subgraphs.
- Parameters
subgraph (
tlp.Graph
) – the subgraph to remove
- tlp.Graph.getSuperGraph()
Returns the parent of the graph, if it has no parent (is the root graph), it returns itself.
- Return type
- tlp.Graph.getRoot()
Returns the root graph of the graph hierarchy.
- Return type
- tlp.Graph.setSuperGraph(superGraph)
Sets the parent of the graph (use very carefully). Standard users should never use this method.
- Parameters
superGraph (
tlp.Graph
) – the new parent for the graph in the hierarchy.
- tlp.Graph.getSubGraphs()
Returns an iterator on all the subgraphs of the graph.
- Return type
a Tulip iterator on
tlp.Graph
objects
- tlp.Graph.isSubGraph(graph)
Returns
True
if the graph argument is a direct subgraph of the graph.- Parameters
graph (
tlp.Graph
) – a graph- Return type
boolean
- tlp.Graph.isDescendantGraph(graph)
Returns
True
if the graph argument is a descendant of this graph.- Parameters
graph (
tlp.Graph
) – a graph- Return type
boolean
- tlp.Graph.getSubGraph(id)
Returns the subgraph with the corresponding id or
None
if there is no subgraph with that id.- Parameters
id (integer) – a graph id
- Return type
tlp.Graph
orNone
- tlp.Graph.getSubGraph(name)
New in version 3.7.
Returns the subgraph with the corresponding name or
None
if there is no subgraph with that name.- Parameters
name (string) – the name of the subgraph to return
- Return type
tlp.Graph
orNone
- tlp.Graph.getDescendantGraph(id)
Returns the descendant graph with the corresponding id or
None
if there is no such descendant graph.- Parameters
id (integer) – a graph id
- Return type
tlp.Graph
orNone
- tlp.Graph.getDescendantGraph(name)
New in version 3.7.
Returns the descendant graph with the corresponding name or
None
if there is no such descendant graph.- Parameters
name (string) – the name of the descendant to return
- Return type
tlp.Graph
orNone
- tlp.Graph.getNthSubGraph(n)
New in version 3.7.
Returns the nth subgraph or
None
if there is no such subgraph. Since order cannot be ensured in every implementation, this method should be equivalent to:i = 0 for sg in graph.getSubGraphs(): if i++ == n: return sg return None
- Parameters
n (integer) – the index of the subgraph to return
- Return type
tlp.Graph
orNone
- tlp.Graph.numberOfSubGraphs()
New in version 3.7.
Returns the number of direct subgraphs.
- Return type
integer
- tlp.Graph.numberOfDescendantGraphs()
New in version 3.7.
Returns the number of descendant graphs.
- Return type
integer
- tlp.Graph.getDescendantGraphs()
Returns an iterator over all the descendant graphs of the graph.
- Return type
a Tulip iterator on
tlp.Graph
objects
Iterators on the graph structure¶
All the provided iterators are stable, meaning you can safely delete a node/edge/subgraph from the graph while iterating on its nodes/edges/subgraphs.
- tlp.Graph.getOneNode()
Returns the first node in the graph.
- Return type
- tlp.Graph.getRandomNode()
New in version 4.8.
Returns a random node in the graph.
- Return type
- tlp.Graph.getNodes()
Returns an iterator on the nodes.
- Return type
a Tulip iterator on
tlp.node
objects
- tlp.Graph.getInNode(node, i)
Returns the ith predecessor of a node.
- Parameters
node (
tlp.node
) – an existing node of the graphi (integer) – the position in the predecessor nodes list (warning: first index is 1 not 0)
- Return type
- Throws
an exception if the node does not belong to the graph or if the requested index is lesser than the number of predecessor nodes
- tlp.Graph.getInNodes(node)
Return an iterator on the predecessors of a node.
- tlp.Graph.getOutNode(node, i)
Returns the ith successor of a node.
- Parameters
node (
tlp.node
) – an existing node of the graphi (integer) – the position in the successor nodes list (warning: first index is 1 not 0)
- Return type
- Throws
an exception if the node does not belong to the graph or if the requested index is lesser than the number of successor nodes
- tlp.Graph.getOutNodes(node)
Returns an iterator on the successors of a node.
- tlp.Graph.getInOutNodes(node)
Returns an iterator on the neighbours of a node.
- tlp.Graph.bfs(root=tlp.node())
New in version 4.2.
Returns an iterator performing a breadth-first search on the graph.
- Parameters
root (
tlp.node
) – The node from whom to start the BFS. If not provided, the root node will be assigned to a source node in the graph (node with input degree equals to 0). If there is no source node in the graph, a random node will be picked.- Return type
a Tulip iterator on
tlp.node
objects in the BFS order.- Throws
an exception if the provided root node does not belong to the graph.
- tlp.Graph.dfs(root=tlp.node())
New in version 4.2.
Returns an iterator performing a depth-first search on the graph.
- Parameters
root (
tlp.node
) – The node from whom to start the DFS. If not provided, the root node will be assigned to a source node in the graph (node with input degree equals to 0). If there is no source node in the graph, a random node will be picked.- Return type
a Tulip iterator on
tlp.node
objects in the DFS order.- Throws
an exception if the provided root node does not belong to the graph.
- tlp.Graph.getNodeMetaInfo(node)
Returns the underlying graph of a meta node.
- tlp.Graph.getOneEdge()
Returns the first edge in the graph.
- Return type
- tlp.Graph.getRandomEdge()
New in version 4.8.
Returns a random edge in the graph.
- Return type
- tlp.Graph.getEdges()
Returns an iterator on the edges.
- Return type
a Tulip iterator on
tlp.edge
objects
- tlp.Graph.getOutEdges(node)
Returns a Tulip iterator on the outgoing edges of a node.
- tlp.Graph.getInOutEdges(node)
Returns an iterator on the incoming and outgoing edges of a node.
- tlp.Graph.getInEdges(node)
Returns an iterator on the incoming edges of a node.
Information about the graph structure¶
- tlp.Graph.nodes()¶
New in version 5.0.
Returns the list of nodes belonging to the graph.
- Return type
list of
tlp.node
- tlp.Graph.nodePos(node)¶
New in version 5.0.
Returns the position of a node in the list of nodes belonging to the graph that can be accessed through the
tlp.Graph.nodes()
method.- Parameters
node (
tlp.node
) – an existing node of the graph- Return type
integer
- Throws
an exception if the node does not belong to the graph
- tlp.Graph.edges()¶
New in version 5.0.
Returns the list of edges belonging to the graph.
- Return type
list of
tlp.node
- tlp.Graph.edgePos(edge)¶
New in version 5.0.
Returns the position of an edge in the list of edges belonging to the graph that can be accessed through the
tlp.Graph.edges()
method.- Parameters
edge – an existing edge of the graph
- Return type
integer
- Throws
an exception if the edge does not belong to the graph
- tlp.Graph.allEdges(node)¶
New in version 5.0.
Returns the list of all edges adjacent to a given node.
- tlp.Graph.subGraphs()¶
New in version 5.2.
Returns the list of direct subgraphs of the graph.
- Return type
list of
tlp.Graph
- tlp.Graph.getId()¶
Returns the graph’s id. This id is unique.
- Return type
integer
- tlp.Graph.getName()¶
Returns the name of the graph.
- Return type
string
- tlp.Graph.setName(name)¶
Sets the name of the graph.
- Parameters
name (string) – the new name of the graph
- tlp.Graph.getAttributes()¶
New in version 4.4.
Returns all the attributes of the graph.
- Return type
a dictionary with string keys filled with graph attributes values
- tlp.Graph.getAttribute(name)¶
Returns a reference on an attribute of the graph or
None
if it does not exist.- Parameters
name (string) – the name of the attribute to return.
- Return type
object
- Throws
an exception is the attribute does not exist
- tlp.Graph.setAttribute(name, val)¶
Sets an attribute of the graph.
- Parameters
name (string) – the name of the attribute to set
val – the value of the attribute
type – object
- tlp.Graph.removeAttribute(name)¶
New in version 4.4.
Removes an attribute of the graph.
- Parameters
name (string) – the name of the attribute to return.
- Return type
object
- Throws
an exception is the attribute does not exist
- tlp.Graph.existAttribute(name)¶
New in version 4.10.
Checks if an attribute with a specific name exists in the graph.
- Parameters
name (string) – the name of the attribute to test existence.
- Return type
boolean
- tlp.Graph.getEdges(node1, node2, directed=True)¶
New in version 4.2.
Returns the edges found between two nodes. If no edge is found, returns edges is empty.
- Parameters
- Return type
boolean
- Throws
an exception if one of the nodes does not belong to the graph
- tlp.Graph.isEmpty()¶
Returns
True
if the graph has no nodes.- Return type
boolean
- tlp.Graph.numberOfNodes()¶
Returns the number of nodes in the graph.
- Return type
integer
- tlp.Graph.numberOfEdges()¶
Returns the number of edges in the graph.
- Return type
integer
- tlp.Graph.deg(node)¶
Returns the degree of a node.
- Parameters
node (
tlp.node
) – an existing node of the graph- Return type
integer
- Throws
an exception if the node does not belong to the graph
- tlp.Graph.indeg(node)¶
Returns the incoming degree of a node.
- Parameters
node (
tlp.node
) – an existing node of the graph- Return type
integer
- Throws
an exception if the node does not belong to the graph
- tlp.Graph.outdeg(node)¶
Returns the outgoing degree of a node.
- Parameters
node (
tlp.node
) – an existing node of the graph- Return type
integer
- Throws
an exception if the node does not belong to the graph
- tlp.Graph.source(edge)¶
Returns the source of the edge.
- tlp.Graph.target(edge)¶
Returns the target of the edge.
- tlp.Graph.ends(edge)¶
Returns a tuple containing the two end nodes of an edge
- tlp.Graph.opposite(edge, node)¶
Returns the opposite node of the edge for the given node.
- tlp.Graph.isElement(node)¶
Returns
True
if the node is an element of the graph.- Parameters
node (
tlp.node
) – a node- Return type
boolean
- tlp.Graph.isMetaNode(node)¶
Returns
True
if the node is a meta-node.- Parameters
node (
tlp.edge
) – an existing node of the graph- Return type
boolean
- Throws
an exception if the node does not belong to the graph
- tlp.Graph.isElement(edge)
Returns
True
if the edge is an element of the graph.- Parameters
edge (
tlp.edge
) – an edge- Return type
boolean
- tlp.Graph.isElement(node)
- Parameters
node (
tlp.node
) – a node- Return type
boolean
- tlp.Graph.isMetaEdge(edge)¶
Returns
True
if the edge is a meta-edge.- Parameters
edge – an existing edge of the graph
- Return type
boolean
- Throws
an exception if the edge does not belong to the graph
- tlp.Graph.existEdge(node1, node2, directed=True)¶
Returns the first edge found between two nodes. If no edge is found, returns an invalid edge.
- Parameters
- Return type
- Throws
an exception if one of the nodes does not belong to the graph
- tlp.Graph.hasEdge(node1, node2, directed=True)¶
New in version 4.2.
Returns true if it exists an edge between two nodes. If no edge is found, returns false.
- Parameters
- Return type
boolean
- Throws
an exception if one of the nodes does not belong to the graph
- tlp.Graph.getSource()¶
New in version 3.7.
Finds the first node whose input degree equals 0. Returns the found node or an invalid one if there is no source.
- Return type
Create/Access graph properties¶
- tlp.Graph.getBooleanProperty(name)¶
Returns the boolean property associated to name in the graph properties pool or in the pool of an ancestor in the subgraphs hierarchy. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the boolean property to return or to create
- Return type
- tlp.Graph.getLocalBooleanProperty(name)¶
Returns the boolean property associated to name in the graph properties pool. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the boolean property to return or to create
- Return type
- tlp.Graph.getBooleanVectorProperty(name)¶
Returns the boolean vector property associated to name in the graph properties pool or in the pool of an ancestor in the subgraphs hierarchy. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the boolean vector property to return or to create
- Return type
- tlp.Graph.getLocalBooleanVectorProperty(name)¶
Returns the boolean vector property associated to name in the graph properties pool. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the boolean vector property to return or to create
- Return type
- tlp.Graph.getColorProperty(name)¶
Returns the color property associated to name in the graph properties pool or in the pool of an ancestor in the subgraphs hierarchy. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the color property to return or to create
- Return type
- tlp.Graph.getLocalColorProperty(name)¶
Returns the color property associated to name in the graph properties pool. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the color property to return or to create
- Return type
- tlp.Graph.getColorVectorProperty(name)¶
Returns the color vector property associated to name in the graph properties pool or in the pool of an ancestor in the subgraphs hierarchy. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the color vector property to return or to create
- Return type
- tlp.Graph.getLocalColorVectorProperty(name)¶
Returns the color vector property associated to name in the graph properties pool. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the color vector property to return or to create
- Return type
- tlp.Graph.getDoubleProperty(name)¶
Returns the double property associated to name in the graph properties pool or in the pool of an ancestor in the subgraphs hierarchy. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the double property to return or to create
- Return type
- tlp.Graph.getLocalDoubleProperty(name)¶
Returns the double property associated to name in the graph properties pool. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the double property to return or to create
- Return type
- tlp.Graph.getDoubleVectorProperty(name)¶
Returns the double vector property associated to name in the graph properties pool or in the pool of an ancestor in the subgraphs hierarchy. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the double vector property to return or to create
- Return type
- tlp.Graph.getLocalDoubleVectorProperty(name)¶
Returns the double vector property associated to name in the graph properties pool. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the double vector property to return or to create
- Return type
- tlp.Graph.getIntegerProperty(name)¶
Returns the integer property associated to name in the graph properties pool or in the pool of an ancestor in the subgraphs hierarchy. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the integer property to return or to create
- Return type
- tlp.Graph.getLocalIntegerProperty(name)¶
Returns the integer property associated to name in the graph properties pool. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the integer property to return or to create
- Return type
- tlp.Graph.getIntegerVectorProperty(name)¶
Returns the integer vector property associated to name in the graph properties pool or in the pool of an ancestor in the subgraphs hierarchy. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the integer vector property to return or to create
- Return type
- tlp.Graph.getLocalIntegerVectorProperty(name)¶
Returns the integer vector property associated to name in the graph properties pool. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the integer vector property to return or to create
- Return type
- tlp.Graph.getGraphProperty(name)¶
Returns the meta-graph property associated to name in the graph properties pool or in the pool of an ancestor in the subgraphs hierarchy. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the meta-graph property to return or to create
- Return type
tlp.GraphProperty
- tlp.Graph.getLocalGraphProperty(name)¶
Returns the meta-graph property associated to name in the graph properties pool. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the meta-graph property to return or to create
- Return type
tlp.GraphProperty
- tlp.Graph.getLayoutProperty(name)¶
Returns the layout property associated to name in the graph properties pool or in the pool of an ancestor in the subgraphs hierarchy. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the layout property to return or to create
- Return type
- tlp.Graph.getLocalLayoutProperty(name)¶
Returns the layout property associated to name in the graph properties pool. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the layout property to return or to create
- Return type
- tlp.Graph.getCoordVectorProperty(name)¶
Returns the coord vector property associated to name in the graph properties pool or in the pool of an ancestor in the subgraphs hierarchy. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the coord vector property to return or to create
- Return type
- tlp.Graph.getLocalCoordVectorProperty(name)¶
Returns the coord vector property associated to name in the graph properties pool. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the coord vector property to return or to create
- Return type
- tlp.Graph.getSizeProperty(name)¶
Returns the size property associated to name in the graph properties pool or in the pool of an ancestor in the subgraphs hierarchy. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the size property to return or to create
- Return type
- tlp.Graph.getLocalSizeProperty(name)¶
Returns the size property associated to name in the graph properties pool. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the size property to return or to create
- Return type
- tlp.Graph.getSizeVectorProperty(name)¶
Returns the size vector property associated to name in the graph properties pool or in the pool of an ancestor in the subgraphs hierarchy. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the size vector property to return or to create
- Return type
- tlp.Graph.getLocalSizeVectorProperty(name)¶
Returns the size vector property associated to name in the graph properties pool. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the size vector property to return or to create
- Return type
- tlp.Graph.getStringProperty(name)¶
Returns the string property associated to name in the graph properties pool or in the pool of an ancestor in the subgraphs hierarchy. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the string property to return or to create
- Return type
- tlp.Graph.getLocalStringProperty(name)¶
Returns the string property associated to name in the graph properties pool. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the string property to return or to create
- Return type
- tlp.Graph.getStringVectorProperty(name)¶
Returns the string vector property associated to name in the graph properties pool or in the pool of an ancestor in the subgraphs hierarchy. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the string vector property to return or to create
- Return type
- tlp.Graph.getLocalStringVectorProperty(name)¶
Returns the string vector property associated to name in the graph properties pool. If the property is not registered in the pool, it creates a new one and returns it. Using of
del
on that property will cause a segmentation violation (usetlp.Graph.delLocalProperty()
instead).- Parameters
name (string) – the name of the string vector property to return or to create
- Return type
- tlp.Graph.getProperty(name)¶
Returns the property associated to name in the graph properties pool. The returned property is referenced by its base class
tlp.PropertyInterface
meaning getting and setting values can only be done via the use of strings. To get the property correctly typed, use the methods described above. If the property does not exist it returnsNone
.- Parameters
name (string) – the name of the property to return
- Return type
- tlp.Graph.existProperty(name)¶
Returns
True
if a property of that name exists in the graph properties pool or in the pool of an ancestor in the subgraphs hierarchy.- Parameters
name (string) – the name of the property
- Return type
boolean
- tlp.Graph.existLocalProperty(name)¶
Returns
True
if a property of that name exists in the graph properties pool.- Parameters
name (string) – the name of the property
- Return type
boolean
- tlp.Graph.delLocalProperty(name)¶
Removes and deletes the property associated to name in the graph properties pool.
- Parameters
name (string) – the name of the property to delete
- tlp.Graph.getLocalProperties()¶
Returns an iterator on the names of the properties local to the graph.
- Return type
a Tulip iterator on string objects
- tlp.Graph.getInheritedProperties()¶
Returns an iterator on the names of the properties inherited from the graph’s ancestors.
- Return type
a Tulip iterator on string objects
- tlp.Graph.getProperties()¶
Returns an iterator on the names of all the properties attached to the graph.
- Return type
a Tulip iterator on string objects
- tlp.Graph.getLocalObjectProperties()¶
New in version 4.8.
Returns an iterator over the local properties attached to the graph.
- Return type
a Tulip iterator on
tlp.PropertyInterface
objects
- tlp.Graph.getInheritedObjectProperties()¶
New in version 4.8.
Returns an iterator over the inherited properties attached to the graph.
- Return type
a Tulip iterator on
tlp.PropertyInterface
objects
- tlp.Graph.getObjectProperties()¶
New in version 4.8.
Returns an iterator over the properties attached to the graph, whether they are local or inherited.
- Return type
a Tulip iterator on
tlp.PropertyInterface
objects
- tlp.Graph.getNodePropertiesValues(node)¶
New in version 4.8.1.
Returns a dictionary containing the attached graph properties values for a given node. The keys of that dictionary are of string type and corresponds to the graph properties names while the values are typed according to those of the properties (bool, int, float, str,
tlp.Color
,tlp.Coord
,tlp.Size
, list of those types).- Parameters
node (
tlp.node
) – a node of the graph- Return type
a dictionary filled with the node properties values
- Throws
an exception if the provided node does not belong to the graph
- tlp.Graph.getEdgePropertiesValues(edge)¶
New in version 4.8.1.
Returns a dictionary containing the attached graph properties values for a given edge. The keys of that dictionary are of string type and corresponds to the graph properties names while the values are typed according to those of the properties (bool, int, float, str,
tlp.Color
,tlp.Coord
,tlp.Size
, list of those types).- Parameters
edge (
tlp.edge
) – an edge of the graph- Return type
a dictionary filled with the edge properties values :throws: an exception if the provided node does not belong to the graph
- tlp.Graph.setNodePropertiesValues(node, propertiesValues)¶
New in version 4.8.1.
Sets the values of multiple graph properties for a given node through the use of a dictionary. The keys of that dictionary must be of string type and correspond to graph properties names (possibly not created yet) while the values must be typed according to those of the available Tulip properties (bool, int, float, str,
tlp.Color
,tlp.Coord
,tlp.Size
, list of those types).- Parameters
node (
tlp.node
) – a node of the graphpropertiesValues (a dictionary) – the properties values for the node
- Throws
an exception if the provided node does not belong to the graph, if one of the string key of the dictionary does not correspond to an existing property name of if there is a type error for a property value
- tlp.Graph.setEdgePropertiesValues(edge, propertiesValues)¶
New in version 4.8.1.
Sets the values of multiple graph properties for a given edge through the use of a dictionary. The keys of that dictionary must be of string type and correspond to graph properties names (possibly not created yet) while the values must be typed according to those of the available Tulip properties (bool, int, float, str,
tlp.Color
,tlp.Coord
,tlp.Size
, list of those types).- Parameters
edge (
tlp.edge
) – an edge of the graphpropertiesValues (a dictionary) – the properties values for the edge
- Throws
an exception if the provided edge does not belong to the graph, if one of the string key of the dictionary does not correspond to an existing property name of if there is a type error for a property value
Application of algorithms¶
- tlp.Graph.applyAlgorithm(algoName, params=None)¶
New in version 3.7.
Applies an algorithm plugin, identified by its name. Algorithm plugins are objects implementing the tlp::Algorithm interface in C++ or the
tlp.Algorithm
interface in Python.Parameters can be transmit to the algorithm using a Python dictionary filled with parameters values where keys are of type string (parameters names) . In some cases, algorithms can also use this dictionary in order to return some external information. To determine a plugin’s parameters, you can either:
refer to its documentation
call the
tlp.getDefaultPluginParameters()
with the name of the plugin
Returns a tuple whose first member is a boolean indicating if the algorithm terminates successfully and second member is a string which can contain an error message.
- Parameters
algoName (string) – The name of the algorithm to apply.
params (a dictionary with string keys (parameters names) and parameters values) – The parameters to the algorithm.
- Return type
(boolean, string)
- tlp.Graph.applyBooleanAlgorithm(algoName, result, params=None)¶
New in version 3.8.
Computes a boolean property on the current graph using an external named boolean algorithm (plugin). Boolean algorithm plugins are objects implementing the tlp::BooleanAlgorithm interface in C++ or the
tlp.BooleanAlgorithm
interface in Python. The list of currently loaded boolean algorithm plugins can be retrieved through thetlp.getBooleanAlgorithmPluginsList()
function. The computed values will be stored in result.Parameters can be transmit to the algorithm using a Python dictionary filled with parameters values where keys are of type string (parameters names) . In some cases, algorithms can also use this dictionary in order to return some external information (not stored in result). To determine a plugin’s parameters, you can either:
refer to its documentation
call the
tlp.getDefaultPluginParameters()
with the name of the plugin
Returns a tuple whose first member is a boolean indicating if the algorithm terminates successfully and second member is a string which can contain an error message.
- Parameters
algoName (string) – the name of the boolean algorithm to call
result (
tlp.BooleanProperty
) – a boolean property in which result of the algorithm will be storedparams (a dictionary with string keys (parameters names) and parameters values) – The parameters to the algorithm.
- Return type
(boolean, string)
- Throws
an exception if the requested boolean algorithm plugin is not registered in the plugins database.
Warning
Previous values stored in result will be deleted.
- tlp.Graph.applyBooleanAlgorithm(algoName, params=None)
New in version 4.8.
Convenient method that computes a boolean property on the current graph and stores the result in the default boolean property “viewSelection”. This is equivalent to call:
graph.applyBooleanAlgorithm(algoName, graph.getBooleanProperty("viewSelection"), params)
- tlp.Graph.applyColorAlgorithm(algoName, result, params=None)¶
New in version 3.8.
Computes a color property on the current graph using an external named color algorithm (plugin). Color algorithm plugins are objects implementing the tlp::ColorAlgorithm interface in C++ or the
tlp.ColorAlgorithm
interface in Python. The list of currently loaded color algorithm plugins can be retrieved through thetlp.getColorAlgorithmPluginsList()
function. The computed values will be stored in result.Parameters can be transmit to the algorithm using a Python dictionary filled with parameters values where keys are of type string (parameters names) . In some cases, algorithms can also use this dictionary in order to return some external information (not stored in result). To determine a plugin’s parameters, you can either:
refer to its documentation
call the
tlp.getDefaultPluginParameters()
with the name of the plugin
Returns a tuple whose first member is a boolean indicating if the algorithm terminates successfully and second member is a string which can contain an error message.
- Parameters
algoName (string) – the name of the color algorithm to call
result (
tlp.ColorProperty
) – a color property in which result of the algorithm will be storedparams (a dictionary with string keys (parameters names) and parameters values) – The parameters to the algorithm.
- Return type
(boolean, string)
- Throws
an exception if the requested color algorithm plugin is not registered in the plugins database.
Warning
Previous values stored in result will be deleted.
- tlp.Graph.applyColorAlgorithm(algoName, params=None)
New in version 4.8.
Convenient method that computes a color property on the current graph and stores the result in the default color property “viewColor”. This is equivalent to call:
graph.applyColorAlgorithm(algoName, graph.getColorProperty("viewColor"), params)
- tlp.Graph.applyDoubleAlgorithm(algoName, result, params=None)¶
New in version 3.8.
Computes a double property on the current graph using an external named double algorithm (plugin). Double algorithm plugins are objects implementing the tlp::DoubleAlgorithm interface in C++ or the
tlp.DoubleAlgorithm
interface in Python. The list of currently loaded double algorithm plugins can be retrieved through thetlp.getDoubleAlgorithmPluginsList()
function. The computed values will be stored in result.Parameters can be transmit to the algorithm using a Python dictionary filled with parameters values where keys are of type string (parameters names) . In some cases, algorithms can also use this dictionary in order to return some external information (not stored in result). To determine a plugin’s parameters, you can either:
refer to its documentation
call the
tlp.getDefaultPluginParameters()
with the name of the plugin
Returns a tuple whose first member is a boolean indicating if the algorithm terminates successfully and second member is a string which can contain an error message.
- Parameters
algoName (string) – the name of the double algorithm to call
result (
tlp.DoubleProperty
) – a double property in which result of the algorithm will be storedparams (a dictionary with string keys (parameters names) and parameters values) – The parameters to the algorithm.
- Return type
(boolean, string)
- Throws
an exception if the requested double algorithm plugin is not registered in the plugins database.
Warning
Previous values stored in result will be deleted.
- tlp.Graph.applyDoubleAlgorithm(algoName, params=None)
New in version 4.8.
Convenient method that computes a double property on the current graph and stores the result in the default double property “viewMetric”. This is equivalent to call:
graph.applyDoubleAlgorithm(algoName, graph.getDoubleProperty("viewMetric"), params)
- tlp.Graph.applyIntegerAlgorithm(algoName, result, params=None)¶
New in version 3.8.
Computes an integer property on the current graph using an external named integer algorithm (plugin). Integer algorithm plugins are objects implementing the tlp::IntegerAlgorithm interface in C++ or the
tlp.IntegerAlgorithm
interface in Python. The list of currently loaded integer algorithm plugins can be retrieved through thetlp.getIntegerAlgorithmPluginsList()
function. The computed values will be stored in result.Parameters can be transmit to the algorithm using a Python dictionary filled with parameters values where keys are of type string (parameters names) . In some cases, algorithms can also use this dictionary in order to return some external information (not stored in result). To determine a plugin’s parameters, you can either:
refer to its documentation
call the
tlp.getDefaultPluginParameters()
with the name of the plugin
Returns a tuple whose first member is a boolean indicating if the algorithm terminates successfully and second member is a string which can contain an error message.
- Parameters
algoName (string) – the name of the integer algorithm to call
result (
tlp.IntegerProperty
) – an integer property in which result of the algorithm will be storedparams (a dictionary with string keys (parameters names) and parameters values) – The parameters to the algorithm.
- Return type
(boolean, string)
- Throws
an exception if the requested integer algorithm plugin is not registered in the plugins database.
Warning
Previous values stored in result will be deleted.
- tlp.Graph.applyLayoutAlgorithm(algoName, result, params=None)¶
New in version 3.8.
Computes a layout property on the current graph using an external named layout algorithm (plugin). Layout algorithm plugins are objects implementing the tlp::LayoutAlgorithm interface in C++ or the
tlp.LayoutAlgorithm
interface in Python. The list of currently loaded layout algorithm plugins can be retrieved through thetlp.getLayoutAlgorithmPluginsList()
function. The computed values will be stored in result.Parameters can be transmit to the algorithm using a Python dictionary filled with parameters values where keys are of type string (parameters names) . In some cases, algorithms can also use this dictionary in order to return some external information (not stored in result). To determine a plugin’s parameters, you can either:
refer to its documentation
call the
tlp.getDefaultPluginParameters()
with the name of the plugin
Returns a tuple whose first member is a boolean indicating if the algorithm terminates successfully and second member is a string which can contain an error message.
- Parameters
algoName (string) – the name of the layout algorithm to call
result (
tlp.LayoutProperty
) – a layout property in which result of the algorithm will be storedparams (a dictionary with string keys (parameters names) and parameters values) – The parameters to the algorithm.
- Return type
(boolean, string)
- Throws
an exception if the requested layout algorithm plugin is not registered in the plugins database.
Warning
Previous values stored in result will be deleted.
- tlp.Graph.applyLayoutAlgorithm(algoName, params=None)
New in version 4.8.
Convenient method that computes a layout property on the current graph and stores the result in the default layout property “viewLayout”. This is equivalent to call:
graph.applyLayoutAlgorithm(algoName, graph.getLayoutProperty("viewLayout"), params)
- tlp.Graph.applySizeAlgorithm(algoName, result, params=None)¶
New in version 3.8.
Computes a size property on the current graph using an external named size algorithm (plugin). Size algorithm plugins are objects implementing the tlp::SizeAlgorithm interface in C++ or the
tlp.SizeAlgorithm
interface in Python. The list of currently loaded size algorithm plugins can be retrieved through thetlp.getSizeAlgorithmPluginsList()
function. The computed values will be stored in result.Parameters can be transmit to the algorithm using a Python dictionary filled with parameters values where keys are of type string (parameters names) . In some cases, algorithms can also use this dictionary in order to return some external information (not stored in result). To determine a plugin’s parameters, you can either:
refer to its documentation
call the
tlp.getDefaultPluginParameters()
with the name of the plugin
Returns a tuple whose first member is a boolean indicating if the algorithm terminates successfully and second member is a string which can contain an error message.
- Parameters
algoName (string) – the name of the size algorithm to call
result (
tlp.SizeProperty
) – a size property in which result of the algorithm will be storedparams (a dictionary with string keys (parameters names) and parameters values) – The parameters to the algorithm.
- Return type
(boolean, string)
- Throws
an exception if the requested size algorithm plugin is not registered in the plugins database.
Warning
Previous values stored in result will be deleted.
- tlp.Graph.applySizeAlgorithm(algoName, params=None)
New in version 4.8.
Convenient method that computes a size property on the current graph and stores the result in the default size property “viewSize”. This is equivalent to call:
graph.applySizeAlgorithm(algoName, graph.getSizeProperty("viewSize"), params)
- tlp.Graph.applyStringAlgorithm(algoName, result, params=None)¶
New in version 3.8.
Computes a string property on the current graph using an external named string algorithm (plugin). String algorithm plugins are objects implementing the tlp::StringAlgorithm interface in C++ or the
tlp.StringAlgorithm
interface in Python. The list of currently loaded string algorithm plugins can be retrieved through thetlp.getStringAlgorithmPluginsList()
function. The computed values will be stored in result. Parameters can be transmit to the algorithm using a Python dictionary filled with parameters values where keys are of type string (parameters names) . In some cases, algorithms can also use this dictionary in order to return some external information (not stored in result). To determine a plugin’s parameters, you can either:refer to its documentation
call the
tlp.getDefaultPluginParameters()
with the name of the plugin
Returns a tuple whose first member is a boolean indicating if the algorithm terminates successfully and second member is a string which can contain an error message.
- Parameters
algoName (string) – the name of the string algorithm to call
result (
tlp.StringProperty
) – a string property in which result of the algorithm will be storedparams (a dictionary with string keys (parameters names) and parameters values) – The parameters to the algorithm.
- Return type
(boolean, string)
- Throws
an exception if the requested string algorithm plugin is not registered in the plugins database.
Warning
Previous values stored in result will be deleted.
- tlp.Graph.applyStringAlgorithm(algoName, params=None)
New in version 4.8.
Convenient method that computes a string property on the current graph and stores the result in the default string property “viewLabel”. This is equivalent to call:
graph.applyStringAlgorithm(algoName, graph.getStringProperty("viewLabel"), params)
Update management¶
- tlp.Graph.push(unpopAllowed=True)¶
Marks the state of the current root graph in the hierarchy. The next updates will be recorded in order to be undone at the next call of the
tlp.Graph.pop()
method. Be careful that all the updates are undone except those who affect the ordering of edges.- Parameters
unpopAllowed (boolean) – If set to
False
, the next updates could not be replayed after undone. If some previously undone updates exist they could no longer be replayed.
- tlp.Graph.pop(unpopAllowed=True)¶
Restores a previously marked state of the current root graph in the hierarchy. The restored state does not remain marked.
- Parameters
unpopAllowed (boolean) – If set to
False
, the undone updates could not be replayed.
- tlp.Graph.unpop()¶
Marks again the current state of the root graph hierarchy and replays the last updates previously undone.
- tlp.Graph.canPop()¶
Returns
True
if a previously marked state can be restored.- Return type
boolean
- tlp.Graph.canUnpop()¶
Returns
True
if some previously undone updates can be replayed.- Return type
boolean
- tlp.Graph.canPopThenUnpop()¶
Returns
True
if the current state updates can be undone then replayed.- Return type
boolean
- tlp.Graph.popIfNoUpdates()¶
New in version 5.0.
Remove last pushed state if no updates have been recorded.
- Return type
boolean
Meta-nodes management¶
- tlp.Graph.createMetaNode(nodes, multiEdges=True, delAllEdge=True, allGrouped=True)¶
New in version 5.0.
Closes a set of existing nodes into a metanode and returns it. Edges from nodes in the set to other nodes are replaced with edges from the metanode to the other nodes.
- Parameters
nodes (list of
tlp.node
) – a list of existing nodesmultiEdges (boolean) – indicates if a meta edge will be created for each underlying edge
delAllEdge (boolean) – indicates if the underlying edges will be removed from the entire hierarchy
allGrouped (boolean) – In the no multi edges case, indicates if the underlying edges will be grouped in a unique meta edge or in one for the in edges and one for the out edges
- Return type
- Throws
an exception if one of the provided nodes does not belong to the graph.
Warning
This method will fail when called on the root graph.
- tlp.Graph.createMetaNode(subgraph, multiEdges=True, delAllEdge=True, allGrouped=True)
Closes a subgraph into a metanode and returns it. Edges from nodes in the subgraph to nodes outside the subgraph are replaced with edges from the metanode to the nodes outside the subgraph.
The provided subgraph can not be a descendant of the current graph in the graph hierarchy. When creating a metanode, all nodes that are closed in it are first deleted from the graph. These nodes are also deleted in the subgraphs of the graph and in all descendant subgraphs. So if the provided subgraph is a descendant of the graph, all its nodes and edges will be deleted and the meta-node will point to an empty subgraph.
- Parameters
subgraph (
tlp.Graph
) – an existing subgraphmultiEdges (boolean) – indicates if a meta edge will be created for each underlying edge
delAllEdge (boolean) – indicates if the underlying edges will be removed from the entire hierarchy
allGrouped (boolean) – In the no multi edges case, indicates if the underlying edges will be grouped in a unique meta edge or in one for the in edges and one for the out edges
- Return type
- Throws
an exception if the provided subgraph is a descendant of the graph in the graph hierarchy or if one of the element in the subgraph does not belong to the graph.
Warning
This method will fail when called on the root graph.
- tlp.Graph.createMetaNodes(itGraph, quotientGraph)¶
Populates a quotient graph with one meta node for each iterated graph. Returns a list of created meta-nodes.
- tlp.Graph.openMetaNode(metaNode, updateProperties=True)¶
Opens a metanode and replaces all edges between that meta node and other nodes in the graph.
- Parameters
metaNode (
tlp.node
) – the meta-node to openupdateProperties (boolean) – If
True
, open meta node will update inner nodes layout, color, size, etc…
Warning
This method will fail when called on the root graph.
Tulip datatypes¶
tlp.Vec3f¶
- class tlp.Vec3f¶
This class represents a vector with 3 floating point components. It can be instantiated as illustrated in the code below:
# Initializes a Vec3f with all components set to 0.0 v = tlp.Vec3f() # Initializes a Vec3f with all components set to 1.0 v2 = tlp.Vec3f(1.0) # Initializes a Vec3f by specifying the value of each component v3 = tlp.Vec3f(1.0, 2.0, 3.0) # Initializes a Vec3f by copy v4 = tlp.Vec3f(v3)
Numerous mathematical operations are available to work with vectors. The sample code below illustrates them:
# Instantiate two vectors v = tlp.Vec3f(4.5, 1.0, 3.0) v2 = tlp.Vec3f(1.5, 2.0, 6.0) # Add two vectors, operator += is also available v3 = v + v2 # Add a value to all components of a vector, operator += is also available v4 = v + 2.0 # Subtract two vectors, operator -= is also available v5 = v - v2 # Subtract a value to all components of a vector, operator -= is also available v6 = v - 3.0 # Multiply two vectors (not vector product), operator *= is also available v7 = v * v2 # Multiply each component of a vector by a value, operator *= is also available v8 = v * 2.0 # Divide two vectors, operator /= is also available v9 = v / v2 # Divide each component of a vector by a value, operator /= is also available v10 = v / 2.0 # Perform a vector product, operator ^= is also available v11 = v ^ v2
Each component of the vector can be read / written through the [] operator:
v = tlp.Vec3f(1.0, 2.0, 3.0) # read first component a = v[0] # write third component v[2] = 4.0
Operators for vectors equality (==), vectors difference (!=) and vectors comparison (<, >) are also available.
- depth()¶
Convenient method. Returns the third component of the vector.
- Return type
float
- dist(v)¶
Computes and returns the distance between the vector (3D point) and another one.
- Parameters
v (
tlp.Vec3f
) – a vector- Return type
float
- dotProduct(v)¶
Computes and returns the dot product (scalar product) of the vector with another one
- Parameters
v (
tlp.Vec3f
) – a vector- Return type
float
- fill(val)¶
Set the same value to each component of the vector.
- Parameters
val (float) – a value
- get()¶
Returns the vector as a tuple.
- Return type
(float, float, float)
- getD()¶
Convenient method. Returns the third component of the vector.
- Return type
float
- getH()¶
Convenient method. Returns the second component of the vector.
- Return type
float
- getW()¶
Convenient method. Returns the first component of the vector.
- Return type
float
- getX()¶
Convenient method. Returns the first component of the vector.
- Return type
float
- getY()¶
Convenient method. Returns the second component of the vector.
- Return type
float
- getZ()¶
Convenient method. Returns the third component of the vector.
- Return type
float
- height()¶
Convenient method. Returns the second component of the vector.
- Return type
float
- norm()¶
Computes and returns the euclidean norm of the vector.
- Return type
float
- set(x, y, z)¶
Sets each component of the vector.
- Parameters
x (float) – the first component value
y (float) – the second component value
z (float) – the third component value
- setD(depth)¶
Convenient method. Sets the third component of the vector.
- Parameters
depth (float) – a value
- setH(height)¶
Convenient method. Sets the second component of the vector.
- Parameters
height (float) – a value
- setW(width)¶
Convenient method. Sets the first component of the vector.
- Parameters
width (float) – a value
- setX(x)¶
Convenient method. Sets the first component of the vector.
- Parameters
x (float) – a value
- setY(y)¶
Convenient method. Sets the second component of the vector.
- Parameters
y (float) – a value
- setZ(z)¶
Convenient method. Sets the third component of the vector.
- Parameters
z (float) – a value
- width()¶
Convenient method. Returns the first component of the vector.
- Return type
float
- x()¶
Convenient method. Returns the first component of the vector.
- Return type
float
- y()¶
Convenient method. Returns the second component of the vector.
- Return type
float
- z()¶
Convenient method. Returns the third component of the vector.
- Return type
float
tlp.Vec4f¶
tlp.Vec4i¶
tlp.Coord¶
- tlp.Coord¶
alias of
_tulip.tlp.Vec3f
tlp.BoundingBox¶
- class tlp.BoundingBox¶
This class represents the 3D bounding box of an object. It is defined by two 3D points, the first one being the lowest point (bottom-left corner), the second being the highest (top-right corner).
A bounding box can be instantiated and manipulated the following ways:
# Initialize a non-valid bounding box. # The minimum is (1, 1, 1) and the maximum is (-1, -1, -1). bb = tlp.BoundingBox() # Initialize a bounding box by specifying the lowest and highest point. # The validity of the bounding box is checked in debug mode (an assertion is raised if it is not valid). bb2 = tlp.BoundingBox(tlp.Vec3f(0,0,0), tlp.Vec3f(10,10,10)) # Reading / writing the bounding box components can be done through the [] operator min = bb2[0] max = bb2[1]
- contains(point)¶
New in version 3.7.
Checks if the given point is inside the current bounding box. If the bounding box is invalid the result is always
False
.- Parameters
point (
tlp.Vec3f
) – a point in the 3D space.- Return type
Boolean
- depth()¶
Returns the depth of the bounding box.
- Return type
float
- expand(point)¶
Expands the bounding box to one containing the vector passed as parameter. If the vector is inside the bounding box, it remains unchanged.
- Parameters
point (
tlp.Vec3f
) – A point in the 3D space we want the bounding box to encompass.
- height()¶
Returns the height of the bounding box.
- Return type
float
- intersect(boundingBox)¶
New in version 3.7.
Checks if the given bounding box intersects the current one. If one of the bounding boxes is invalid returns
False
.- Parameters
boundingBox (
tlp.BoundingBox
) – the bounding box on which to check intersection- Return type
Boolean
- intersect(segStart, segEnd)
New in version 3.7.
Checks if the bounding box intersects the given line segment. If the bounding box is invalid the result is always
False
.
- isValid()¶
Checks whether the bounding box’s lowest point is less than it’s highest point. “Less Than” means axis-by-axis comparison, i.e. x1 < x2 && y1 < y2 && z1 < z2.
- Return type
Boolean
- translate(displacement)¶
Translates the bounding box by the displacement given by the vector passed as parameter.
- Parameters
displacement (
tlp.Vec3f
) – The displacement vector in 3D space to translate this bounding box by.
- width()¶
Returns the width of the bounding box.
- Return type
float
tlp.Size¶
tlp.Color¶
- class tlp.Color¶
This class represents a color using the RGBA color space. It can be instantiated the following way:
# Each component must be in the range [0, 255] redOpaque = tlp.Color(255, 0, 0) blueTranslucent = tlp.Color(0, 0, 255, 100)
The value of each component can be read / written using the [] operator.
- getA()¶
Returns the alpha component of the color.
- Return type
integer
- getAGL()¶
Returns the alpha component of the color in the OpenGL format (a float value between 0.0 and 1.0).
- Return type
float
- getB()¶
Returns the blue component of the color.
- Return type
integer
- getBGL()¶
Returns the blue component of the color in the OpenGL format (a float value between 0.0 and 1.0).
- Return type
float
- getG()¶
Returns the green component of the color.
- Return type
integer
- getGGL()¶
Returns the green component of the color in the OpenGL format (a float value between 0.0 and 1.0).
- Return type
float
- getH()¶
Returns the hue component (in the range [0, 360]) of the color in the HSV color space.
- Return type
integer
- getR()¶
Returns the red component of the color.
- Return type
integer
- getRGL()¶
Returns the red component of the color in the OpenGL format (a float value between 0.0 and 1.0).
- Return type
float
- getS()¶
Returns the saturation component (in the range [0, 255]) of the color in the HSV color space.
- Return type
integer
- getV()¶
Returns the value component (in the range [0, 255]) of the color in the HSV color space.
- Return type
integer
- set(red, green, blue, alpha)¶
Sets each component of the color. Each component must be in the range [0, 255].
- Parameters
red (integer) – the red component value
green (integer) – the green component value
blue (integer) – the blue component value
alpha (integer) – the alpha component value
- setA(alpha)¶
Sets the alpha component of the color (must be in the range [0, 255]).
- Parameters
alpha (integer) – the alpha component value
- setB(blue)¶
Sets the blue component of the color (must be in the range [0, 255]).
- Parameters
blue (integer) – the blue component value
- setG(green)¶
Sets the green component of the color (must be in the range [0, 255]).
- Parameters
green (integer) – the green component value
- setH(hue)¶
Sets the hue component of the color in the HSV color space (must be in the range [0, 360]).
- Parameters
hue (integer) – the hue component value
- setR(red)¶
Sets the red component of the color (must be in the range [0, 255]).
- Parameters
red (integer) – the red component value
- setS(saturation)¶
Sets the saturation component of the color in the HSV color space (must be in the range [0, 255]).
- Parameters
saturation (integer) – the saturation component value
- setV(value)¶
Sets the value component of the color in the HSV color space (must be in the range [0, 255]).
- Parameters
value (integer) – the value component value
tlp.ColorScale¶
- class tlp.ColorScale¶
This class represents a color scale to perform color mapping. The color scale can be either a gradient or defined by colors associated to consecutive intervals. If the color scale is a gradient, returned colors are interpolated in function of a position between 0.0 and 1.0. If the color scale is not a gradient returned colors are computed according to the interval the position belongs to.
The sample code below illustrates how to create and manipulate a color scale:
# Creates an empty color scale (default constructor creates a heatmap from blue to red). colorScale = tlp.ColorScale([]) # Color scale initialization : from blue to red with gradient. colorScale.setColorAtPos(0.0, tlp.Color.Blue) colorScale.setColorAtPos(1.0, tlp.Color.Red) # The following syntaxes could also be used # colors = [tlp.Color.Blue, tlp.Color.Red] # colorScale.setColorScale(colors) # or # colorScale = tlp.ColorScale(colors) # # colorsMap = {0: tlp.Color.Blue, 1: tlp.Color.Red} # colorScale.setColorMap(colors) # or # colorScale = tlp.ColorScale(colorsMap) # Gets the color for the position 0.5, i.e. tlp.Color(127,0,127). color = colorScale.getColorAtPos(0.5); # Reinitializes the color scale : from blue to red without gradient. newColors = [tlp.Color.Blue, tlp.Color.Red] colorScale.setColorScale(newColors,False) # Gets the color for the position 0.3, i.e. tlp.Color(0,0,255). color = colorScale.getColorAtPos(0.3) # Gets the color for the position 0.7, i.e. tlp.Color(255,0,0). color = colorScale.getColorAtPos(0.7)
Since Tulip 4.10, color scales can also be defined in a more Pythonic way through the use of a list or a dictionary. (see No need to use the tlp.ColorScale class directly as plugin parameter anymore).
- clear()¶
New in version 4.10.
Clears the color scale.
- colorScaleInitialized()¶
New in version 4.10.
Returns :const;`True` if the color scale is initialized, i.e. the underlying color map is not empty.
- Return type
Boolean
- getColorAtPos(pos)¶
This method computes the color associated to a specific position in the color scale and returns it.
- Parameters
pos (float) – This value defines the position of the color in the scale and must be between 0.0 and 1.0 (it will be clamped otherwise).
- Return type
- getColorMap()¶
Returns a dictionary corresponding to the color scale.
- Return type
a dictionary whose indexes are of type float and the values of type
tlp.Color
- hasRegularStops()¶
New in version 4.10.
Returns
True
if the color scale has regular stop points, meaning the distance between each consecutive stop is constant.- Return type
Boolean
- isGradient()¶
Returns
True
if the color scale is a gradient.- Return type
Boolean
- setColorAtPos(pos, color)¶
This method adds a color to the color scale at a specific position.
- Parameters
pos (float) – the position in the color scale (0.0 <= pos <= 1.0)
color (
tlp.Color
) – the color to add at the specified position
- setColorMap(colorMap)¶
New in version 4.10.
Sets the map of stop points and colors used to perform color mapping.
Warning
The keys of the map must be between 0.0 and 1.0, other values will be ignored.
- Parameters
colorMap (a dictionary with float keys and
tlp.Color
values) – the color map that defines the color scale
- setColorMapTransparency(alpha)¶
New in version 4.10.
Sets the transparency of all the colors in the underlying map.
- Parameters
alpha (integer) – the alpha value of each colors (0 <= alpha <= 255)
- setColorScale(colors, gradient=True)¶
This method configures the color scale from a list of colors and associates regular stop points to them.
Warning
If the scale was previously configured the old configuration is lost.
- Parameters
colors (list of
tlp.Color
) – The colors to use in the color scale.gradient (Boolean) – If set to
True
, the color scale is a gradient
- setGradient(gradient)¶
Specify whether the color scale must be considered as a gradient.
- Parameters
gradient (Boolean) – the flag value
tlp.StringCollection¶
- class tlp.StringCollection¶
Deprecated since version 4.8: You should never have to use that class directly from now on. Algorithm parameters of that type are now internally handled for commodity of use (see Deprecation of direct use of the tlp.StringCollection class).
This class represents a list of selectable string entries that can be used as plugin parameter. The list will appear as a combo box in the Plugin Parameter Dialog from the Tulip GUI.
- at(index)¶
Returns the string element at a certain index in the collection.
- Parameters
index (integer) – a valid index in the collection
- Return type
string
- empty()¶
Returns
True
if the collection is empty.- Return type
boolean
- getCurrent()¶
Returns the index of the current selected string.
- Return type
integer
- getCurrentString()¶
Returns the current selected string value.
- Return type
string
- push_back(element)¶
Adds a string value to this string collection.
- Parameters
element (string) – the string to add to the collection
- setCurrent(index)¶
Sets the current selected string index. Returns
True
if the provided index is valid.- Parameters
index (integer) – a valid index in the string collection
- Return type
boolean
- setCurrent(value)
Sets the current selected string value. Returns
True
if the string value exists in the collection.- Parameters
value (string) – a string value from the collection
- Return type
boolean
- size()¶
Returns the number of strings in the collection.
- Return type
integer
tlp.DataSet¶
- class tlp.DataSet¶
Deprecated since version 4.8: The direct use of that class is now deprecated as it is now mapped to a Python dictionary for commodity of use (see Deprecation of direct use of the tlp.DataSet class).
This class is used to store a set of parameters to transmit to a Tulip algorithm. Below is an exhaustive list of data types that can be stored in a Tulip data set:
Boolean
integer
float
string
list of those types
If you try to store an unsupported data type, an exception will be thrown. Each value stored in a data set is associated to a string key. Reading / Writing a value in a data set is done through the [] operator as illustrated below:
# data set creation dataSet = tlp.DataSet() # writing integer values dataSet["height"] = 100 dataSet["width"] = 300 # reading integer values area = dataSet["height"] * dataSet["width"]
When reading a data set value, a reference is returned not a copy.
- getKeys()¶
Returns the list of keys associated to the values stored in the data set.
- Return type
list of string
- remove(key)¶
Remove the value associated to a particular key from the data set if it exists.
- Parameters
key (string) – the key of the value to remove.
- size()¶
Returns the number of values stored in the data set.
- Return type
integer
- toDict()¶
Converts that data set to a Python dictionary.
- Return type
a dictionary reflecting the data set content
tlp.PluginProgress¶
- class tlp.PluginProgress¶
This interface allows to notify and control the progression of a process.
- cancel()¶
Sets the state flag to cancel, notifying to the process that the user wants to cancel it. Canceling a process must stop it and revert all the changes performed since its start.
- getError()¶
Returns a message describing the error encountered during the process. If no error has been encountered, an empty string is returned.
- Return type
string
- isPreviewMode()¶
Returns
True
if the preview mode is enabled. The preview mode redraws the graph while applying the algorithm, making it slower.- Return type
boolean
- progress(step, maxStep)¶
Use this method to notify the progression of the process.
- Parameters
step (integer) – the current step number
maxStep (integer) – the total number of steps
- Return type
a value indicating whether the progress has been stopped (
tlp.ProgressState.TLP_STOP
), cancelled (tlp.ProgressState.TLP_CANCEL
), or will continue (tlp.ProgressState.TLP_CONTINUE
).
- setComment(msg)¶
Changes the comment about the process progression.
- Parameters
msg (string) – A description of what the process is currently doing, displayed to inform the user.
- setError(errorMsg)¶
Sets the message describing the error encountered during the process.
- Parameters
errorMsg (string) – the error message to set
- setPreviewMode(preview)¶
Enables / disables the preview mode. The preview mode redraws the graph while applying the algorithm, making it slower.
- Parameters
preview (boolean) – indicates if the preview mode should be activated
- showPreview(showPreview)¶
This tells the widget associated to this PluginProgress if it should show a preview checkbox, allowing the user to decide if the algorithm should draw a preview or not.
- Parameters
showPreview (boolean) – whether the progress widget should contain a preview checkbox or not.
- state()¶
Gets the current internal state of the PluginProgress.
- Return type
a value indicating whether the progress has been stopped (
tlp.TLP_STOP
), cancelled (tlp.TLP_CANCEL
), or will continue (tlp.TLP_CONTINUE
).
- stop()¶
Sets the state flag to stop, notifying to the process that the user wants to stop it. Stopping a process does not revert changes.
Tulip observation mechanism¶
tlp.Event¶
- class tlp.Event¶
This class is the base one for representing an event in Tulip. Events are objects sent by objects whose classes derives from the
tlp.Observable
one. An event is characterized by its type. The basetlp.Event
class only carries information as to the type of event, nothing specific :tlp.Event.EventType.TLP_DELETE
: send directly to all observers/listeners, not affected bytlp.Observable.holdObservers()
.tlp.Event.EventType.TLP_MODIFICATION
: sent to all observers/listeners. That type of event is first sent to observers then to listeners.tlp.Event.EventType.TLP_INFORMATION
: sent only to listeners.tlp.Event.EventType.TLP_INVALID
: never sent, used internally for delaying events.
Implement a class derived from
tlp.Event
to add custom events. Here is a sample code below:class MyEvent(tlp.Event): # sender must be an instance deriving from tlp.Observable def __init__(self, sender, data): tlp.Event.__init__(self, sender, tlp.Event.EventType.TLP_MODIFICATION) self.data = data def getData(self): return self.data
- class EventType(value)¶
An enumeration.
- sender()¶
Returns the object that sent the event.
- Return type
tlp.Observable
or one of its derived type.
- type()¶
Returns the type of the event.
- Return type
tlp.Event.EventType.TLP_DELETE
ortlp.Event.EventType.TLP_MODIFICATION
ortlp.Event.EventType.TLP_INFORMATION
ortlp.Event.EventType.TLP_INVALID
tlp.GraphEvent¶
- class tlp.GraphEvent¶
That class represents an event that happened on a
tlp.Graph
instance. To get the graph that sent the event, use thetlp.GraphEvent.getGraph()
. The type of graph event can be retrieved through thetlp.GraphEvent.getType()
method. Below is an exhaustive list of those types :tlp.GraphEvent.GraphEventType.TLP_ADD_NODE
: a node has been added in the graph (usetlp.GraphEvent.getNode()
to get the concerned node)tlp.GraphEvent.GraphEventType.TLP_BEFORE_DEL_NODE
: a node is about to be deleted in the graph (usetlp.GraphEvent.getNode()
to get the concerned node)tlp.GraphEvent.GraphEventType.TLP_AFTER_DEL_NODE
: a node has been deleted in the graph (usetlp.GraphEvent.getNode()
to get the concerned node)tlp.GraphEvent.GraphEventType.TLP_ADD_EDGE
: an edge has been added in the graph (usetlp.GraphEvent.getEdge()
to get the concerned edge)tlp.GraphEvent.GraphEventType.TLP_BEFORE_DEL_EDGE
: an edge is about to be deleted in the graph (usetlp.GraphEvent.getEdge()
to get the concerned edge)tlp.GraphEvent.GraphEventType.TLP_AFTER_DEL_EDGE
: an edge has been deleted in the graph (usetlp.GraphEvent.getEdge()
to get the concerned edge)tlp.GraphEvent.GraphEventType.TLP_REVERSE_EDGE
: the direction of an edge has been reversed in the graph (usetlp.GraphEvent.getEdge()
to get the concerned edge)tlp.GraphEvent.GraphEventType.TLP_BEFORE_SET_ENDS
: the extremities of an edge is about to be modified (usetlp.GraphEvent.getEdge()
to get the concerned edge)tlp.GraphEvent.GraphEventType.TLP_AFTER_SET_ENDS
: the extremities of an edge have been modified (usetlp.GraphEvent.getEdge()
to get the concerned edge)tlp.GraphEvent.GraphEventType.TLP_ADD_NODES
: several nodes have been added in the graph (usetlp.GraphEvent.getNodes()
to get the list of concerned nodes)tlp.GraphEvent.GraphEventType.TLP_ADD_EDGES
: several edges have been added in the graph (usetlp.GraphEvent.getEdges()
to get the list of concerned edges)tlp.GraphEvent.GraphEventType.TLP_BEFORE_ADD_DESCENDANTGRAPH
: a descendant graph (i.e. not necessarily a direct subgraph) is about to be added in the subgraphs hierarchy. Usetlp.GraphEvent.getSubGraph()
to get it.tlp.GraphEvent.GraphEventType.TLP_AFTER_ADD_DESCENDANTGRAPH
: a descendant graph (i.e. not necessarily a direct subgraph) has been added in the subgraphs hierarchy. Usetlp.GraphEvent.getSubGraph()
to get it.tlp.GraphEvent.GraphEventType.TLP_BEFORE_DEL_DESCENDANTGRAPH
: a descendant graph (i.e. not necessarily a direct subgraph) is about to be removed in the subgraphs hierarchy. Usetlp.GraphEvent.getSubGraph()
to get it.tlp.GraphEvent.GraphEventType.TLP_AFTER_DEL_DESCENDANTGRAPH
: a descendant graph (i.e. not necessarily a direct subgraph) has been removed in the subgraphs hierarchy. Usetlp.GraphEvent.getSubGraph()
to get it.tlp.GraphEvent.GraphEventType.TLP_BEFORE_ADD_SUBGRAPH
: a subgraph is about to be added in the graph. Usetlp.GraphEvent.getSubGraph()
to get it.tlp.GraphEvent.GraphEventType.TLP_AFTER_ADD_SUBGRAPH
: a subgraph has been added in the graph. Usetlp.GraphEvent.getSubGraph()
to get it.tlp.GraphEvent.GraphEventType.TLP_BEFORE_DEL_SUBGRAPH
: a subgraph is about to be removed in the graph. Usetlp.GraphEvent.getSubGraph()
to get it.tlp.GraphEvent.GraphEventType.TLP_AFTER_DEL_SUBGRAPH
: a subgraph has been removed in the graph. Usetlp.GraphEvent.getSubGraph()
to get it.tlp.GraphEvent.GraphEventType.TLP_BEFORE_ADD_LOCAL_PROPERTY
: a local property is about to be added in the graph. Usetlp.GraphEvent.getPropertyName()
to get the name of the concerned property.tlp.GraphEvent.GraphEventType.TLP_ADD_LOCAL_PROPERTY
: a local property has been added in the graph. Usetlp.GraphEvent.getPropertyName()
to get the name of the concerned property.tlp.GraphEvent.GraphEventType.TLP_BEFORE_DEL_LOCAL_PROPERTY
: a local property is about to be deleted in the graph. Usetlp.GraphEvent.getPropertyName()
to get the name of the concerned property.tlp.GraphEvent.GraphEventType.TLP_AFTER_DEL_LOCAL_PROPERTY
: a local property has been deleted in the graph. Usetlp.GraphEvent.getPropertyName()
to get the name of the concerned property.tlp.GraphEvent.GraphEventType.TLP_BEFORE_ADD_INHERITED_PROPERTY
: an inherited property (not attached to the graph itself but one of its parent) is about to be added in the graph. Usetlp.GraphEvent.getPropertyName()
to get the name of the concerned property.tlp.GraphEvent.GraphEventType.TLP_ADD_INHERITED_PROPERTY
: an inherited property (not attached to the graph itself but one of its parent) has been added in the graph. Usetlp.GraphEvent.getPropertyName()
to get the name of the concerned property.tlp.GraphEvent.GraphEventType.TLP_BEFORE_DEL_INHERITED_PROPERTY
: an inherited property (not attached to the graph itself but one of its parent) is about to be deleted in the graph. Usetlp.GraphEvent.getPropertyName()
to get the name of the concerned property.tlp.GraphEvent.GraphEventType.TLP_AFTER_DEL_INHERITED_PROPERTY
: an inherited property (not attached to the graph itself but one of its parent) has been deleted in the graph. Usetlp.GraphEvent.getPropertyName()
to get the name of the concerned property.tlp.GraphEvent.GraphEventType.TLP_BEFORE_SET_ATTRIBUTE
: an attribute of the graph is about to be set/modified. Usetlp.GraphEvent.getAttributeName()
to get the name of the concerned attribute.tlp.GraphEvent.GraphEventType.TLP_AFTER_SET_ATTRIBUTE
: an attribute of the graph has been set/modified. Usetlp.GraphEvent.getAttributeName()
to get the name of the concerned attribute.tlp.GraphEvent.GraphEventType.TLP_REMOVE_ATTRIBUTE
: an attribute of the graph has been removed. Usetlp.GraphEvent.getAttributeName()
to get the name of the concerned attribute.tlp.GraphEvent.GraphEventType.TLP_BEFORE_RENAME_LOCAL_PROPERTY
: a local property of the graph is about to be renamed. Usetlp.GraphEvent.getProperty()
to get the concerned property andtlp.GraphEvent.getPropertyNewName()
to get the new property name.tlp.GraphEvent.GraphEventType.TLP_AFTER_RENAME_LOCAL_PROPERTY
: a local property of the graph has been renamed. Usetlp.GraphEvent.getProperty()
to get the concerned property andtlp.GraphEvent.getPropertyOldName()
to get the old property name.
- class GraphEventType(value)¶
An enumeration.
- getAttributeName()¶
Returns the name of the attribute concerned by the event (if any, otherwise returns an empty string)
- Return type
string
- getEdge()¶
Returns the edge concerned by the event (if any, otherwise return an invalid edge)
- Return type
- getEdges()¶
Returns the edges concerned by the event (if any, otherwise return an empty list)
- Return type
list of
tlp.edge
- getNode()¶
Returns the node concerned by the event (if any, otherwise return an invalid node)
- Return type
- getNodes()¶
Returns the nodes concerned by the event (if any, otherwise return an empty list)
- Return type
list of
tlp.node
- getProperty()¶
Returns the property that is about to be or has been renamed.
- Return type
- getPropertyName()¶
Returns the name of the property concerned by the event (if any, otherwise returns an empty string)
- Return type
string
- getPropertyNewName()¶
Returns the new name of the property that it is about to be renamed.
- Return type
string
- getPropertyOldName()¶
Returns the old name of the property when it has been renamed.
- Return type
string
- getSubGraph()¶
Returns the subgraph or descendant graph concerned by the event (if any, return
None
otherwise)- Return type
- getType()¶
Returns the type of graph event.
- Return type
tlp.GraphEvent.GraphEventType.TLP_*
(cf. class description above)
tlp.PropertyEvent¶
- class tlp.PropertyEvent¶
That class represents an event that happened on a
tlp.PropertyInterface
derived instance. To get the property that sent the event, use thetlp.PropertyEvent.getProperty()
. The type of property event can be retrieved through thetlp.PropertyEvent.getType()
method. Below is an exhaustive list of those types :tlp.PropertyEvent.PropertyEventType.TLP_BEFORE_SET_NODE_VALUE
: the value of a node is about to be modified. Usetlp.PropertyEvent.getNode()
to get the concerned node.tlp.PropertyEvent.PropertyEventType.TLP_AFTER_SET_NODE_VALUE
: the value of a node has been modified. Usetlp.PropertyEvent.getNode()
to get the concerned node.tlp.PropertyEvent.PropertyEventType.TLP_BEFORE_SET_EDGE_VALUE
: the value of an edge is about to be modified. Usetlp.PropertyEvent.getEdge()
to get the concerned edge.tlp.PropertyEvent.PropertyEventType.TLP_AFTER_SET_EDGE_VALUE
: the value of an edge has been modified. Usetlp.PropertyEvent.getEdge()
to get the concerned edge.tlp.PropertyEvent.PropertyEventType.TLP_BEFORE_SET_ALL_NODE_VALUE
: the value of all nodes is about to be modified.tlp.PropertyEvent.PropertyEventType.TLP_AFTER_SET_ALL_NODE_VALUE
: the value of all nodes has been modified.tlp.PropertyEvent.PropertyEventType.TLP_BEFORE_SET_ALL_EDGE_VALUE
: the value of all edges is about to be modified.tlp.PropertyEvent.PropertyEventType.TLP_AFTER_SET_ALL_EDGE_VALUE
: the value of all edges has been modified.
- class PropertyEventType(value)¶
An enumeration.
- getEdge()¶
Returns the edge concerned by the event (if any, otherwise return an invalid edge)
- Return type
- getNode()¶
Returns the node concerned by the event (if any, otherwise return an invalid node)
- Return type
- getProperty()¶
Returns the property concerned by the event.
- Return type
derived instances of
tlp.PropertyInterface
- getType()¶
- Return type
tlp.GraphEvent.TLP_*
(cf. class description above)
tlp.Observable¶
- class tlp.Observable¶
The
tlp.Observable
class is the base of Tulip’s observation system.Each class that wishes to send or receive notifications needs to inherit from
tlp.Observable
.Tulip has two separate mechanisms of observation : Observers and Listeners. These two mechanisms work through the same class, the difference lies in the way an Observer or Listener is attached to the object whose events it will receive.
The Listener is closer to the original pattern, where events are sent directly to the recipient. The Observer is a twist for performance purposes, it can receive the events in a delayed fashion, and cannot know if the event was just sent or was delayed.
The purpose of this twist is to allow algorithms that perform a high number of modifications (e.g. creating a grid to route edges, creating multiple subgraphs with metrics or layouts) to run smoothly without overcrowding the event queue. As events are sent for every graph modification (e.g. adding a node, deleting a node, setting a value on a node), the sheer quantity of events sent by these algortithms would cause a big performance hit.
This is avoided by using the static method
tlp.Observable.holdObservers()
. This holds all events in a queue and only sends them when the static methodtlp.Observable.unholdObservers()
is called.The only exception to this mechanism is the
tlp.Event.EventType.TLP_DELETE
kind of event, that is never held back. Think of it as an unmaskable POSIX signal; whatever the connection to the object and the state of holdObserver, this event will get through. This is used to prevent crashes in the case where and object is listened or observed and is deleted, as it is likely the recipient keeps a pointer to the now deleted object.The Listener however is not affected by the use of
tlp.Observable.holdObservers()
andtlp.Observable.unholdObservers()
.The observables Observers and Listeners are internally stocked in a graph structure, allowing to visualize the connections easily. This eases debugging of observation-related bugs.
Events are always sent to Listeners first, and then to Observers, even when there is no hold.
To receive events, inherit from
tlp.Observable
, and implement one of two virtual functions.To received events without delay, implement method
tlp.Observable.treatEvent()
. To attach to an object for receiving events, call itstlp.Observable.addListener()
method.To receive events after a delay, implement method
tlp.Observable.treatEvents
. To attach to an object for receiving events, call itstlp.Observable.addObserver()
method.- addListener(listener)¶
Adds a Listener to this object. The Listener will receive events regardless of the state of
tlp.Observable.holdObservers()
andtlp.Observable.unholdObservers()
.- Parameters
listener (
tlp.Observable
) – The object that will receive events.
- addObserver(observer)¶
Adds an Observer to this object. The Observer will receive events sent by this object, if there is no hold applied.
- Parameters
observer (
tlp.Observable
) – The object that will receive events.
- countListeners()¶
Gets the number of Listeners attached to this object.
- Return type
integer
- countObservers()¶
Gets the number of Observers attached to this object.
- Return type
integer
- getReceived()¶
Gets the number of received events.
- Return type
integer
- getSent()¶
Gets the number of sent events.
- Return type
integer
- hasOnlookers()¶
Returns whether there are Observers/Listeners attached to this object.
- Return type
boolean
- holdObservers()¶
Holds back all events until
tlp.Observable.unholObservers()
is called. Listeners are not affected by this function. Once this function is called, all events heading to an Observer will be held, excepttlp.Event.EventType.TLP_DELETE
events. The events are stored in a queue, and will be sent oncetlp.Observable.unholObservers()
is called. It is possible to nest calls totlp.Observable.holObservers()
andtlp.Observable.unholObservers()
, and in this case the events will only be sent when there have been as many calls totlp.Observable.unholObservers()
as totlp.Observable.holObservers()
. It is possible to check whether the events are being help by checking thetlp.Observable.observersHoldCounter()
function.
- observersHoldCounter()¶
Static method to get the number of times
tlp.Observable.holdObservers()
has been called without a matchingtlp.Observable.unholdObservers()
call.- Return type
integer
- removeListener(listener)¶
Removes a Listener from this object. The Listener will no longer receive events from this object.
- Parameters
listener (
tlp.Observable
) – The Listener to remove from this object.
- removeObserver(observer)¶
Removes an Observer from this object. The Observer will no longer receive events from this object.
- Parameters
observer (
tlp.Observable
) – The Observer to remove from this object.
- sendEvent(event)¶
Sends an event to all the Observers/Listeners.
- Parameters
event (
tlp.Event
) – the event to send to the Listeners/Observers.
- treatEvent(event)¶
This function is called when events are sent to the Listeners, and Listeners only. Is it passed a reference to the event that just happened. Implement that method to catch events with custom types (like for instance
tlp.GraphEvent
ortlp.PropertyEvent
)- Parameters
event (
tlp.Event
or types deriving from it) – The event that was sent.
- treatEvents(events)¶
This function is called when events are sent to Observers, and Observers only.
It is passed a list of all the events that happened since the last call. If events were on hold, this vector can be pretty large, and if events were not on hold it is likely it only contains a single element. It is important to note that custom events can not be caught with that method. Only instances of base
tlp.Event
type are stored in the list. Moreover when unholding events through a call totlp.Observable.unholdObservers()
, if several events were sent from the same object, only one instance oftlp.Event
will be stored in the list for that sender.- Parameters
events (list of
tlp.Event
) – The events that happened since the lasttlp.Observable.unholdObservers()
call.
- unholdObservers()¶
Static method to send all held events to the Observers.
Listeners are not affected by this function.
Graph properties classes¶
tlp.PropertyInterface¶
- class tlp.PropertyInterface¶
- clonePrototype(g, name)¶
Returns a newly created property of the same type in the graph g.
- Parameters
g (
tlp.Graph
) – the graph in with the new property will be addedname (string) – the name of the property to create and return
- Return type
- erase(node)¶
Removes the value stored for the node given in parameter. The new value for the node is the default one.
- Parameters
node (
tlp.node
) – an existing node- Throws
an exception if the node does not belong to the graph attached to the property
- getCppClassName()¶
Returns a string giving the name of a the PropertyInterface subclass e.g, “tlp::BooleanProperty”, “tlp::DoubleProperty”, …
- Return type
string
- getEdgeDefaultStringValue()¶
Returns a string representation of the edge default value.
- Return type
string
- getEdgeStringValue(edge)¶
Returns a string conversion of the value registered for the given edge.
- Parameters
edge (
tlp.edge
) – an existing edge- Return type
string
- Throws
an exception if the edge does not belong to the graph attached to the property
- getGraph()¶
Returns the graph on which the property has been defined.
- Return type
Warning
If the property is inherited the graph could be different that the one used to get that property.
- getName()¶
Returns the name of the property.
- Return type
string
- getNodeDefaultStringValue()¶
Returns a string representation of the node default value.
- Return type
string
- getNodeStringValue(node)¶
Returns a string conversion of the value registered for the given node.
- Parameters
node (
tlp.node
) – an existing node- Return type
string
- Throws
an exception if the node does not belong to the graph attached to the property
- getNonDefaultValuatedEdges(subgraph=None)¶
Returns an iterator on all edges whose value is different from the default value.
- Parameters
subgraph (
tlp.Graph
) – a subgraph can be given in parameter. In that case, only the edges owned by this subgraph are returned by the iterator.- Return type
tlp.IteratorEdge
- getNonDefaultValuatedNodes(subgraph=None)¶
Returns an iterator on all nodes whose value is different from the default value.
- Parameters
subgraph (
tlp.Graph
) – a subgraph can be given in parameter. In that case, only the nodes owned by this subgraph are returned by the iterator.- Return type
tlp.IteratorNode
- getTypename()¶
Returns a string describing the type of the property, i.e. “graph”, “double”, “layout”, “string”, “integer”, “color”, “size”, …
- Return type
string
- hasNonDefaultValuatedEdges(subgraph=None)¶
New in version 5.2: Returns whether it exists edges whose value is different from the default value.
- param subgraph
a subgraph can be given in parameter. In that case, only the edges belonging to this subgraph are considered.
- type subgraph
- rtype
boolean
- hasNonDefaultValuatedNodes(subgraph=None)¶
New in version 5.2: Returns whether it exists nodes whose value is different from the default value.
- param subgraph
a subgraph can be given in parameter. In that case, only the nodes belonging to this subgraph are considered.
- type subgraph
- rtype
boolean
- numberOfNonDefaultValuatedEdges(subgraph=None)¶
New in version 4.8: Returns the number of edges whose value is different from the default value.
- param subgraph
a subgraph can be given in parameter. In that case, only the number of edges in this subgraph whose value is different from the default one is returned.
- type subgraph
- rtype
integer
- numberOfNonDefaultValuatedNodes(subgraph=None)¶
New in version 4.8: Returns the number of nodes whose value is different from the default value.
- param subgraph
a subgraph can be given in parameter. In that case, only the number of nodes in this subgraph whose value is different from the default one is returned.
- type subgraph
- rtype
integer
- setAllEdgeStringValue(str)¶
Sets all the edges value to the value represented by a string. All previous values are lost and the represented value is assigned as the default one to the future added edges.
Returns
True
if the given string representation has been successfully converted to a value,False
otherwise.- Parameters
str (string) – a string representation of a value
- Return type
boolean
- setAllNodeStringValue(str)¶
Sets all the nodes value to the value represented by a string. All previous values are lost and the represented value is assigned as the default one to the future added nodes.
Returns
True
if the given string representation has been successfully converted to a value,False
otherwise.- Parameters
str (string) – a string representation of a value
- Return type
boolean
- setEdgeDefaultStringValue(str)¶
New in version 5.0.
Sets the value assigned as the default one to the future added edges from a string representation.
Returns
True
if the given string representation has been successfully converted to a value,False
otherwise.- Parameters
str (string) – a string representing the new value to set on future added edges.
- Return type
boolean
- setEdgeStringValue(edge, str)¶
Registers a new value for the given edge in converting the given string representation. Returns
True
if the given string representation has been successfully converted to a value,False
otherwise.- Parameters
edge (
tlp.edge
) – an existing edgestr (string) – a string representation of a value
- Return type
boolean
- Throws
an exception if the edge does not belong to the graph attached to the property
- setNodeDefaultStringValue(str)¶
New in version 5.0.
Sets the value assigned as the default one to the future added nodes from a string representation.
Returns
True
if the given string representation has been successfully converted to a value,False
otherwise.- Parameters
str (string) – a string representing the new value to set on future added nodes.
- Return type
boolean
- setNodeStringValue(node, str)¶
Registers a new value for the given node in converting the given string representation. Returns
True
if the given string representation has been successfully converted to a value,False
otherwise.- Parameters
node (
tlp.node
) – an existing nodestr (string) – a string representation of a value
- Return type
boolean
- Throws
an exception if the node does not belong to the graph attached to the property
- setStringValueToGraphEdges(str, graph)¶
New in version 5.0.
Sets the same value for all edges in a graph in converting the given string representation of a value. Only the edges from that descendant graph will have their value modified in the property and the default edge value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property, no edge value will be modified in it.
Returns
True
if the given string representation has been successfully converted to a value,False
otherwise.- Parameters
str (string) – a string representation of a value
graph (
tlp.Graph
) – a graph that defines a set of edges
- Return type
boolean
- setStringValueToGraphNodes(str, graph)¶
New in version 5.0.
Sets the same value for all nodes in a graph in converting the given string representation of a value. Only the nodes from that graph will have their value modified in the property and the default node value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property, no node value will be modified in it.
Returns
True
if the given string representation has been successfully converted to a value,False
otherwise.- Parameters
str (string) – a string representation of a value
graph (
tlp.Graph
) – a graph that defines a set of nodes
- Return type
boolean
tlp.BooleanProperty¶
- class tlp.BooleanProperty¶
Bases:
tlp.PropertyInterface
- copy(nodeDst, nodeSrc, prop, ifNotDefault=False)¶
New in version 3.8.
Copies the value hold by a property on a node to another node in this property.
- Parameters
nodeDst (
tlp.node
) – the node to copy the value to.nodeSrc (
tlp.node
) – the node to copy the value from.prop (
tlp.BooleanProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(edgeDst, edgeSrc, prop, ifNotDefault=False)
New in version 3.8.
Copies the value hold by a property on an edge to another edge in this property.
- Parameters
edgeDst (
tlp.edge
) – the node to copy the value to.edgeSrc (
tlp.edge
) – the node to copy the value from.prop (
tlp.BooleanProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(prop)
New in version 3.8.
Copies the values hold by a property in this property.
- Parameters
prop (
tlp.BooleanProperty
) – the property to copy
- getNodesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all nodes belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all edges belonging to the attached graph whose associated value is equal to the one given in parameter.
- reverse(graph=None)¶
Reverses all values associated to graph elements, i.e
True
=>False
,False
=>True
.- Parameters
graph (
tlp.Graph
) – a subgraph can be given in parameter, in that case reverse only values of elements belonging to that subgraph
- reverseEdgeDirection(graph=None)¶
Reverses all the direction of edges in the attached graph which are set to
True
in this Boolean property.- Parameters
graph (
tlp.Graph
) – a subgraph can be given in parameter, in that case reverse only the direction of edges belonging to it
- getEdgeDefaultValue()¶
Returns the default value associated to the edges.
- Return type
boolean
- getEdgeValue(edge)¶
Returns the value associated to a particular edge.
- Parameters
edge (
tlp.edge
) – an existing edge- Return type
boolean
- Throws
an exception if the edge does not belong to the graph attached to the property
- getNodeDefaultValue()¶
Returns the default value associated to the nodes.
- Return type
boolean
- getNodeValue(node)¶
Returns the value associated to a particular node.
- Parameters
node (
tlp.node
) – an existing node- Return type
boolean
- Throws
an exception if the node does not belong to the graph attached to the property
- setAllEdgeValue(val)¶
Sets the same value for all edges. All previous values are lost and the given value is assigned as the default one to the future added edges.
- Parameters
val (boolean) – the value to set on the edges.
- setAllEdgeValue(val)
All previous values are lost and the given value is assigned as the default one to the future added edges.
- Parameters
val (boolean) – the value to set on the edges.
- setAllNodeValue(val)¶
Sets the same value for all nodes. All previous values are lost and the given value is assigned as the default one to the future added nodes.
- Parameters
val (boolean) – the value to set on the nodes.
- setAllNodeValue(val)
All previous values are lost and the given value is assigned as the default one to the future added nodes.
- Parameters
val (boolean) – the value to set on the nodes.
- setValueToGraphNodes(val, graph)¶
New in version 5.0.
Sets the same value for all nodes in a graph. Only the nodes from that graph will have their value modified in the property and the default node value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property (including itself), no node value will be modified in it.
- Parameters
val (boolean) – the value to set on the nodes.
graph (
tlp.Graph
) – a graph that defines a set of nodes
- setValueToGraphEdges(val, graph)¶
New in version 5.0.
Sets the same value for all edges in a graph. Only the edges from that graph will have their value modified in the property and the default edge value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property (including itself), no node value will be modified in it.
- Parameters
val (boolean) – the value to set on the edges.
graph (
tlp.Graph
) – a graph that defines a set of edges
- setEdgeValue(edge, val)¶
Sets the value of a particular edge.
- Parameters
edge (
tlp.edge
) – an existing edgeval (boolean) – the value to set on the edge
- Throws
an exception if the edge does not belong to the graph attached to the property
- setNodeValue(node, val)¶
Sets the value of a particular node.
- Parameters
node (
tlp.node
) – an existing nodeval (boolean) – the value to set on the node
- Throws
an exception if the node does not belong to the graph attached to the property
- setNodeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added nodes.
- Parameters
val (boolean) – the new value to set on future added nodes.
- setEdgeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added edges.
- Parameters
val (boolean) – the new value to set on future added edges.
tlp.ColorProperty¶
- class tlp.ColorProperty¶
Bases:
tlp.PropertyInterface
- copy(nodeDst, nodeSrc, prop, ifNotDefault=False)¶
New in version 3.8.
Copies the value hold by a property on a node to another node in this property.
- Parameters
nodeDst (
tlp.node
) – the node to copy the value to.nodeSrc (
tlp.node
) – the node to copy the value from.prop (
tlp.ColorProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(edgeDst, edgeSrc, prop, ifNotDefault=False)
New in version 3.8.
Copies the value hold by a property on an edge to another edge in this property.
- Parameters
edgeDst (
tlp.edge
) – the node to copy the value to.edgeSrc (
tlp.edge
) – the node to copy the value from.prop (
tlp.ColorProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(prop)
New in version 3.8.
Copies the values hold by a property in this property.
- Parameters
prop (
tlp.ColorProperty
) – the property to copy
- getNodesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all nodes belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all edges belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgeValue(edge)¶
Returns the value associated to a particular edge.
- getNodeValue(node)¶
Returns the value associated to a particular node.
- setAllEdgeValue(val)¶
Sets the same value for all edges. All previous values are lost and the given value is assigned as the default one to the future added edges.
- Parameters
val (
tlp.Color
) – the value to set on the edges.
- setAllEdgeValue(val)
All previous values are lost and the given value is assigned as the default one to the future added edges.
- Parameters
val (
tlp.Color
) – the value to set on the edges.
- setAllNodeValue(val)¶
Sets the same value for all nodes. All previous values are lost and the given value is assigned as the default one to the future added nodes.
- Parameters
val (
tlp.Color
) – the value to set on the nodes.
- setAllNodeValue(val)
All previous values are lost and the given value is assigned as the default one to the future added nodes.
- Parameters
val (
tlp.Color
) – the value to set on the nodes.
- setValueToGraphNodes(val, graph)¶
New in version 5.0.
Sets the same value for all nodes in a graph. Only the nodes from that graph will have their value modified in the property and the default node value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property (including itself), no node value will be modified in it.
- setValueToGraphEdges(val, graph)¶
New in version 5.0.
Sets the same value for all edges in a graph. Only the edges from that graph will have their value modified in the property and the default edge value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property (including itself), no node value will be modified in it.
- setEdgeValue(edge, val)¶
Sets the value of a particular edge.
- setNodeValue(node, val)¶
Sets the value of a particular node.
tlp.NumericProperty¶
- class tlp.NumericProperty¶
Bases:
tlp.PropertyInterface
- copyProperty(graph)¶
New in version 5.0.
Creates a property of the same numeric type of that property (integer or float). The new property will be a copy of this property’s values for all the elements of the graph.
- Parameters
graph (
tlp.Graph
) – The graph in which to create the new property- Return type
- edgesUniformQuantification(n)¶
Performs an uniform quantification on edges based on the values stored in that double property. An uniform quantification tries to separate the edges in n classes of equivalent size according to theirs values in increasing order.
- Parameters
n (integer) – the number of desired classes
Warning
All previous values on edges will be erased and replaced by the id of the class they belong to.
- getEdgeDoubleDefaultValue()¶
Returns the default value associated to the edges.
- Return type
float
- getEdgeDoubleMax(subgraph=None)¶
Returns the maximum value on the edges for that double property.
- Parameters
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case return the maximum value on the edges belonging to that subgraph.- Return type
float
- getEdgeDoubleMin(subgraph=None)¶
Returns the minimum value on the edges for that property.
- Parameters
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case return the minimum value on the edges belonging to that subgraph.- Return type
float
- getEdgeDoubleValue(edge)¶
Returns the value associated to a particular edge.
- Parameters
edge (
tlp.edge
) – an existing edge- Return type
float
- Throws
an exception if the edge does not belong to the graph attached to the property
- getNodeDoubleDefaultValue()¶
Returns the default value associated to the nodes.
- Return type
float
- getNodeDoubleMax(subgraph=None)¶
Returns the maximum value on the nodes for that property.
- Parameters
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case return the maximum value on the nodes belonging to that subgraph.- Return type
float
- getNodeDoubleMin(subgraph=None)¶
Returns the minimum value on the nodes for that property.
- Parameters
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case return the minimum value on the nodes belonging to that subgraph.- Return type
float
- getNodeDoubleValue(node)¶
Returns the value associated to a particular node.
- Parameters
node (
tlp.node
) – an existing node- Return type
float
- Throws
an exception if the node does not belong to the graph attached to the property
- getSortedEdges(subgraph=None, ascendingOrder=True)¶
New in version 4.8.
Gets an iterator sorting edges according to their values in that numeric property.
- getSortedEdgesByExtremitiesValues(subgraph=None, ascendingOrder=True)¶
New in version 4.8.
Gets an iterator sorting edges according to the values of their extremities in that numeric property. Vectors of two numbers (first element being the source node value, second one the target node value) are compared in that case.
- getSortedEdgesBySourceValue(subgraph=None, ascendingOrder=True)¶
New in version 4.8.
Gets an iterator sorting edges according to the values of their source nodes in that numeric property.
- getSortedEdgesByTargetValue(subgraph=None, ascendingOrder=True)¶
New in version 4.8.
Gets an iterator sorting edges according to the values of their target nodes in that numeric property.
- getSortedNodes(subgraph=None, ascendingOrder=True)¶
New in version 4.8.
Gets an iterator sorting nodes according to their values in that numeric property.
- nodesUniformQuantification(n)¶
Performs an uniform quantification on nodes based on the values stored in that property. An uniform quantification tries to separate the nodes in n classes of equivalent size according to theirs values in increasing order.
- Parameters
n (integer) – the number of desired classes
Warning
All previous values on nodes will be erased and replaced by the id of the class they belong to.
- uniformQuantification(n)¶
Performs an uniform quantification on nodes and edges based on the values stored in that property. An uniform quantification tries to separate the nodes and edges in n classes of equivalent size according to theirs values in increasing order.
- Parameters
n (integer) – the number of desired classes
Warning
All previous values on nodes and edges will be erased and replaced by the id of the class they belong to.
tlp.DoubleProperty¶
- class tlp.DoubleProperty¶
Bases:
tlp.NumericProperty
- copy(nodeDst, nodeSrc, prop, ifNotDefault=False)¶
New in version 3.8.
Copies the value hold by a property on a node to another node in this property.
- Parameters
nodeDst (
tlp.node
) – the node to copy the value to.nodeSrc (
tlp.node
) – the node to copy the value from.prop (
tlp.DoubleProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(edgeDst, edgeSrc, prop, ifNotDefault=False)
New in version 3.8.
Copies the value hold by a property on an edge to another edge in this property.
- Parameters
edgeDst (
tlp.edge
) – the node to copy the value to.edgeSrc (
tlp.edge
) – the node to copy the value from.prop (
tlp.DoubleProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(prop)
New in version 3.8.
Copies the values hold by a property in this property.
- Parameters
prop (
tlp.DoubleProperty
) – the property to copy
- getNodesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all nodes belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all edges belonging to the attached graph whose associated value is equal to the one given in parameter.
- getNodeMin(subgraph=None)¶
Returns the minimum value on the nodes for that double property.
- Parameters
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case return the minimum value on the nodes belonging to that subgraph.- Return type
float
- getNodeMax(subgraph=None)¶
Returns the maximum value on the nodes for that double property.
- Parameters
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case return the maximum value on the nodes belonging to that subgraph.- Return type
float
- getEdgeMin(subgraph=None)¶
Returns the minimum value on the edges for that double property.
- Parameters
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case return the minimum value on the edges belonging to that subgraph.- Return type
float
- getEdgeMax(subgraph=None)¶
Returns the maximum value on the edges for that double property.
- Parameters
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case return the maximum value on the edges belonging to that subgraph.- Return type
float
- getEdgeDefaultValue()¶
Returns the default value associated to the edges.
- Return type
float
- getEdgeValue(edge)¶
Returns the value associated to a particular edge.
- Parameters
edge (
tlp.edge
) – an existing edge- Return type
float
- Throws
an exception if the edge does not belong to the graph attached to the property
- getNodeDefaultValue()¶
Returns the default value associated to the nodes.
- Return type
float
- getNodeValue(node)¶
Returns the value associated to a particular node.
- Parameters
node (
tlp.node
) – an existing node- Return type
float
- Throws
an exception if the node does not belong to the graph attached to the property
- setAllEdgeValue(val)¶
Sets the same value for all edges. All previous values are lost and the given value is assigned as the default one to the future added edges.
- Parameters
val (float) – the value to set on the edges.
- setAllNodeValue(val)¶
Sets the same value for all nodes. All previous values are lost and the given value is assigned as the default one to the future added nodes.
- Parameters
val (float) – the value to set on the nodes.
- setValueToGraphNodes(val, graph)¶
New in version 5.0.
Sets the same value for all nodes in a graph. Only the nodes from that graph will have their value modified in the property and the default node value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property (including itself), no node value will be modified in it.
- Parameters
val (float) – the value to set on the nodes.
graph (
tlp.Graph
) – a graph that defines a set of nodes
- setValueToGraphEdges(val, graph)¶
New in version 5.0.
Sets the same value for all edges in a graph. Only the edges from that graph will have their value modified in the property and the default edge value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property (including itself), no node value will be modified in it.
- Parameters
val (float) – the value to set on the edges.
graph (
tlp.Graph
) – a graph that defines a set of edges
- setEdgeValue(edge, val)¶
Sets the value of a particular edge.
- Parameters
edge (
tlp.edge
) – an existing edgeval (float) – the value to set on the edge
- Throws
an exception if the edge does not belong to the graph attached to the property
- setNodeValue(node, val)¶
Sets the value of a particular node.
- Parameters
node (
tlp.node
) – an existing nodeval (float) – the value to set on the node
- Throws
an exception if the node does not belong to the graph attached to the property
- setNodeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added nodes.
- Parameters
val (float) – the new value to set on future added nodes.
- setEdgeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added edges.
- Parameters
val (float) – the new value to set on future added edges.
- setMetaValueCalculator(nodeCalc=tlp.DoubleProperty.StandardMetaValueCalculator.AVG_CALC, edgeCalc=tlp.DoubleProperty.StandardMetaValueCalculator.AVG_CALC)¶
Sets the predefined calculator for meta-nodes and meta-edges. It is used to compute the value of a double property for each meta-node and meta-edge based on the aggregated nodes and edges. The available calculators are:
tlp.DoubleProperty.StandardMetaValueCalculator.NO_CALC: do nothing
tlp.DoubleProperty.StandardMetaValueCalculator.AVG_CALC: computes the average value of the grouped elements
tlp.DoubleProperty.StandardMetaValueCalculator.SUM_CALC: computes the sum of the grouped elements
tlp.DoubleProperty.StandardMetaValueCalculator.MAX_CALC: computes the maximum value of the grouped elements
tlp.DoubleProperty.StandardMetaValueCalculator.MIN_CALC: computes the minimum value of the grouped elements
- Parameters
nodeCalc (tlp.DoubleProperty.StandardMetaValueCalculator) – a predefined calculator value used for nodes
edgeCalc (tlp.DoubleProperty.StandardMetaValueCalculator) – a predefined calculator value used for edges
tlp.IntegerProperty¶
- class tlp.IntegerProperty¶
Bases:
tlp.NumericProperty
- copy(nodeDst, nodeSrc, prop, ifNotDefault=False)¶
New in version 3.8.
Copies the value hold by a property on a node to another node in this property.
- Parameters
nodeDst (
tlp.node
) – the node to copy the value to.nodeSrc (
tlp.node
) – the node to copy the value from.prop (
tlp.IntegerProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(edgeDst, edgeSrc, prop, ifNotDefault=False)
New in version 3.8.
Copies the value hold by a property on an edge to another edge in this property.
- Parameters
edgeDst (
tlp.edge
) – the node to copy the value to.edgeSrc (
tlp.edge
) – the node to copy the value from.prop (
tlp.IntegerProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(prop)
New in version 3.8.
Copies the values hold by a property in this property.
- Parameters
prop (
tlp.IntegerProperty
) – the property to copy
- getNodesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all nodes belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all edges belonging to the attached graph whose associated value is equal to the one given in parameter.
- getNodeMin(subgraph=None)¶
Returns the minimum value on the nodes for that integer property.
- Parameters
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case return the minimum value on the nodes belonging to that subgraph.- Return type
integer
- getNodeMax(subgraph=None)¶
Returns the maximum value on the nodes for that integer property.
- Parameters
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case return the maximum value on the nodes belonging to that subgraph.- Return type
integer
- getEdgeMin(subgraph=None)¶
Returns the minimum value on the edges for that integer property.
- Parameters
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case return the minimum value on the edges belonging to that subgraph.- Return type
integer
- getEdgeMax(subgraph=None)¶
Returns the maximum value on the edges for that integer property.
- Parameters
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case return the maximum value on the edges belonging to that subgraph.- Return type
integer
- getEdgeDefaultValue()¶
Returns the default value associated to the edges.
- Return type
integer
- getEdgeValue(edge)¶
Returns the value associated to a particular edge.
- Parameters
edge (
tlp.edge
) – an existing edge- Return type
integer
- Throws
an exception if the edge does not belong to the graph attached to the property
- getNodeDefaultValue()¶
Returns the default value associated to the nodes.
- Return type
integer
- getNodeValue(node)¶
Returns the value associated to a particular node.
- Parameters
node (
tlp.node
) – an existing node- Return type
integer
- Throws
an exception if the node does not belong to the graph attached to the property
- setAllEdgeValue(val)¶
Sets the same value for all edges. All previous values are lost and the given value is assigned as the default one to the future added edges.
- Parameters
val (integer) – the value to set on the edges.
- setAllNodeValue(val)¶
Sets the same value for all nodes. All previous values are lost and the given value is assigned as the default one to the future added nodes.
- Parameters
val (integer) – the value to set on the nodes.
- setValueToGraphNodes(val, graph)¶
New in version 5.0.
Sets the same value for all nodes in a graph. Only the nodes from that graph will have their value modified in the property and the default node value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property (including itself), no node value will be modified in it.
- Parameters
val (integer) – the value to set on the nodes.
graph (
tlp.Graph
) – a graph that defines a set of nodes
- setValueToGraphEdges(val, graph)¶
New in version 5.0.
Sets the same value for all edges in a graph. Only the edges from that graph will have their value modified in the property and the default edge value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property (including itself), no node value will be modified in it.
- Parameters
val (integer) – the value to set on the edges.
graph (
tlp.Graph
) – a graph that defines a set of edges
- setEdgeValue(edge, val)¶
Sets the value of a particular edge.
- Parameters
edge (
tlp.edge
) – an existing edgeval (integer) – the value to set on the edge
- Throws
an exception if the edge does not belong to the graph attached to the property
- setNodeValue(node, val)¶
Sets the value of a particular node.
- Parameters
node (
tlp.node
) – an existing nodeval (integer) – the value to set on the node
- Throws
an exception if the node does not belong to the graph attached to the property
- setNodeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added nodes.
- Parameters
val (integer) – the new value to set on future added nodes.
- setEdgeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added edges.
- Parameters
val (integer) – the new value to set on future added edges.
tlp.LayoutProperty¶
- class tlp.LayoutProperty¶
Bases:
tlp.PropertyInterface
- angularResolutions(node, subgraph=None)¶
Returns a list of all angular resolution of a node. It is only defined for 2D drawing, meaning the third coordinates is omitted
- Parameters
- Return type
list of float
- Throws
an exception if the node does not belong to the graph attached to the property or if the provided subgraph is not a descendant of the graph attached to the property
- averageAngularResolution(subgraph=None)¶
Returns the average angular resolution of the layout. It is only defined for 2D drawing, meaning the third coordinate is omitted
- Parameters
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case computes the average angular resolution for the layout of the nodes belonging to that subgraph.- Return type
float
- Throws
an exception if the provided subgraph is not a descendant of the graph attached to the property
- averageAngularResolution(node, subgraph=None)
Returns the average angular resolution of a node. It is only defined for 2D drawing, meaning the third coordinate is omitted
- Parameters
- Return type
float
- Throws
an exception if the node does not belong to the graph attached to the property or if the provided subgraph is not a descendant of the graph attached to the property
- averageEdgeLength(subgraph=None)¶
New in version 3.7.
Returns the average edge length of the layout, the bends are taken into account.
- Parameters
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case only computes the average edge length for that subgraph.- Return type
float
- Throws
an exception if the provided subgraph is not a descendant of the graph attached to the property
- center(subgraph=None)¶
Centers the layout, meaning translating it in order that the center of its bounding box is (0,0,0)
- Parameters
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case only centers the layout of that subgraph.- Throws
an exception if the provided subgraph is not a descendant of the graph attached to the property
- center(newCenter, subgraph=None)
New in version 3.7.
Centers the layout to newCenter, meaning translating it in order that the center of its bounding box is equal to newCenter.
- computeEmbedding(subgraph=None)¶
Fixes embedding of the graph according to the layout, ie. sort edges around nodes according to their neighbors/bends position in the layout. Only works in 2D, the third coordinate is not taken into account.
- Parameters
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case fixes embedding of that subgraph- Throws
an exception if the provided subgraph is not a descendant of the graph attached to the property
- computeEmbedding(node, subgraph=None)
Fixes embedding of the node according to the layout, ie. sort edges around the node according to their neighbors/bends position in the layout. Only works in 2D, the third coordinate is not taken into account.
- Parameters
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case fixes embedding of the node in that subgraph- Throws
an exception if the node does not belong to the graph attached to the property or if the provided subgraph is not a descendant of the graph attached to the property
- copy(nodeDst, nodeSrc, prop, ifNotDefault=False)¶
New in version 3.8.
Copies the value hold by a property on a node to another node in this property.
- Parameters
nodeDst (
tlp.node
) – the node to copy the value to.nodeSrc (
tlp.node
) – the node to copy the value from.prop (
tlp.LayoutProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(edgeDst, edgeSrc, prop, ifNotDefault=False)
New in version 3.8.
Copies the value hold by a property on an edge to another edge in this property.
- Parameters
edgeDst (
tlp.edge
) – the node to copy the value to.edgeSrc (
tlp.edge
) – the node to copy the value from.prop (
tlp.LayoutProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(prop)
New in version 3.8.
Copies the values hold by a property in this property.
- Parameters
prop (
tlp.LayoutProperty
) – the property to copy
- getNodesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all nodes belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all edges belonging to the attached graph whose associated value is equal to the one given in parameter.
- edgeLength(edge)¶
Returns the length of an edge, the bends are taken into account. Thus, it measures the length of a polyline.
- Parameters
edge (
tlp.edge
) – an existing edge- Return type
float
- Throws
an exception if the edge does not belong to the graph attached to the property
Warning
This function only measures the length of the polyline between bends, when using curves like Bezier etc… the result will not be the length of the curve.
- getMin(subgraph=None)¶
Returns the minimum coordinate in that layout property, i.e. the bottom-left corner of the graph drawing bounding box.
- getMax(subgraph=None)¶
Returns the maximum coordinate in that layout property, i.e. the top-right corner of the graph drawing bounding box.
- normalize(subgraph=None)¶
Normalizes the layout, meaning dividing each nodes and edges coordinate by the maximum magnitude of the whole coordinates set
- Parameters
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case only normalizes the layout of that subgraph.- Throws
an exception if the provided subgraph is not a descendant of the graph attached to the property
- perfectAspectRatio(subgraph=None)¶
Scales the layout in order to approach an aspect ratio (width / height) of 1.0.
- Parameters
subgraph – a subgraph can be given in parameter, in that case only scales the layout of that subgraph.
- rotateX(alpha, subgraph=None)¶
New in version 3.7.
Rotates the layout around the X-axis according to an angle in degrees.
- Parameters
alpha (float) – an angle in degrees
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case rotates the layout of the nodes belonging to that subgraph.
- Throws
an exception if the provided subgraph is not a descendant of the graph attached to the property
- rotateX(alpha, itNodes, itEdges)
Rotates the layout around the X-axis of the nodes and edges provided through iterators according to an angle in degrees.
- Parameters
alpha (float) – an angle in degrees
itNodes (
tlp.IteratorNode
) – an iterator on graph nodesitEdges (
tlp.IteratorEdge
) – an iterator on graph edges
- rotateY(alpha, subgraph=None)¶
New in version 3.7.
Rotates the layout around the Y-axis according to an angle in degrees.
- Parameters
alpha (float) – an angle in degrees
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case rotates the layout of the nodes belonging to that subgraph.
- Throws
an exception if the provided subgraph is not a descendant of the graph attached to the property
- rotateY(alpha, itNodes, itEdges)
Rotates the layout around the Y-axis of the nodes and edges provided through iterators according to an angle in degrees.
- Parameters
alpha (float) – an angle in degrees
itNodes (
tlp.IteratorNode
) – an iterator on graph nodesitEdges (
tlp.IteratorEdge
) – an iterator on graph edges
- rotateZ(alpha, subgraph=None)¶
Rotates the layout around the Z-axis according to an angle in degrees.
- Parameters
alpha (float) – an angle in degrees
subgraph (
tlp.Graph
) – a subgraph can be given in parameter, in that case rotates the layout of the nodes belonging to that subgraph.
- Throws
an exception if the provided subgraph is not a descendant of the graph attached to the property
- rotateZ(alpha, itNodes, itEdges)
Rotates the layout around the Z-axis of the nodes and edges provided through iterators according to an angle in degrees.
- Parameters
alpha (float) – an angle in degrees
itNodes (
tlp.IteratorNode
) – an iterator on graph nodesitEdges (
tlp.IteratorEdge
) – an iterator on graph edges
- scale(scaleFactors, subgraph=None)¶
Scales the layout according to a vector of scale factors (sx, sy, sz).
- scale(scaleFactors, itNodes, itEdges)
Scales the layout of the nodes and edges provided through iterators according to a vector of scale factors (sx, sy, sz).
- Parameters
move (
tlp.Vec3f
) – a vector of scale factorsitNodes (
tlp.IteratorNode
) – an iterator on graph nodesitEdges (
tlp.IteratorEdge
) – an iterator on graph edges
- translate(move, subgraph=None)¶
Translates the current layout according to a movement vector.
- translate(move, itNodes, itEdges)
Translates the layout of a set of nodes and edges provided through iterators according to a movement vector.
- Parameters
move (
tlp.Vec3f
) – a movement vectoritNodes (
tlp.IteratorNode
) – an iterator on graph nodesitEdges (
tlp.IteratorEdge
) – an iterator on graph edges
- getEdgeDefaultValue()¶
Returns the default value associated to the edges.
- Return type
list of
tlp.Coord
- getEdgeValue(edge)¶
Returns the value associated to a particular edge.
- getNodeValue(node)¶
Returns the value associated to a particular node.
- setAllEdgeValue(val)¶
Sets the same value for all edges. All previous values are lost and the given value is assigned as the default one to the future added edges.
- Parameters
val (list of
tlp.Coord
) – the value to set on the edges.
- setAllNodeValue(val)¶
Sets the same value for all nodes. All previous values are lost and the given value is assigned as the default one to the future added nodes.
- Parameters
val (
tlp.Coord
) – the value to set on the nodes.
- setEdgeValue(edge, val)¶
Sets the value of a particular edge.
- setNodeValue(node, val)¶
Sets the value of a particular node.
tlp.SizeProperty¶
- class tlp.SizeProperty¶
Bases:
tlp.PropertyInterface
- copy(nodeDst, nodeSrc, prop, ifNotDefault=False)¶
New in version 3.8.
Copies the value hold by a property on a node to another node in this property.
- Parameters
nodeDst (
tlp.node
) – the node to copy the value to.nodeSrc (
tlp.node
) – the node to copy the value from.prop (
tlp.SizeProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(edgeDst, edgeSrc, prop, ifNotDefault=False)
New in version 3.8.
Copies the value hold by a property on an edge to another edge in this property.
- Parameters
edgeDst (
tlp.edge
) – the node to copy the value to.edgeSrc (
tlp.edge
) – the node to copy the value from.prop (
tlp.SizeProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(prop)
New in version 3.8.
Copies the values hold by a property in this property.
- Parameters
prop (
tlp.SizeProperty
) – the property to copy
- getNodesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all nodes belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all edges belonging to the attached graph whose associated value is equal to the one given in parameter.
- getMin(subgraph=None)¶
Returns the minimum value on the nodes for that size property.
- getMax(subgraph=None)¶
Returns the maximum value on the nodes for that size property.
- scale(scaleFactors, subgraph=None)¶
Scales the sizes of the nodes and edges according to a scale factors vector (sx, sy, sz).
- scale(scaleFactors, itNodes, itEdges)
Scales the sizes of the nodes and edges provided through iterators according to a scale factors vector (sx, sy, sz).
- Parameters
scaleFactors (
tlp.Size
) – a vector of scale factorsitNodes (
tlp.IteratorNode
) – an iterator on graph nodesitEdges (
tlp.IteratorEdge
) – an iterator on graph edges
- getEdgeValue(edge)¶
Returns the value associated to a particular edge.
- getNodeValue(node)¶
Returns the value associated to a particular node.
- setAllEdgeValue(val)¶
Sets the same value for all edges. All previous values are lost and the given value is assigned as the default one to the future added edges.
- Parameters
val (
tlp.Size
) – the value to set on the edges.
- setAllNodeValue(val)¶
Sets the same value for all nodes. All previous values are lost and the given value is assigned as the default one to the future added nodes.
- Parameters
val (
tlp.Size
) – the value to set on the nodes.
- setValueToGraphNodes(val, graph)¶
New in version 5.0.
Sets the same value for all nodes in a graph. Only the nodes from that graph will have their value modified in the property and the default node value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property (including itself), no node value will be modified in it.
- setValueToGraphEdges(val, graph)¶
New in version 5.0.
Sets the same value for all edges in a graph. Only the edges from that graph will have their value modified in the property and the default edge value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property (including itself), no node value will be modified in it.
- setEdgeValue(edge, val)¶
Sets the value of a particular edge.
- setNodeValue(node, val)¶
Sets the value of a particular node.
tlp.StringProperty¶
- class tlp.StringProperty¶
Bases:
tlp.PropertyInterface
- copy(nodeDst, nodeSrc, prop, ifNotDefault=False)¶
New in version 3.8.
Copies the value hold by a property on a node to another node in this property.
- Parameters
nodeDst (
tlp.node
) – the node to copy the value to.nodeSrc (
tlp.node
) – the node to copy the value from.prop (
tlp.StringProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(edgeDst, edgeSrc, prop, ifNotDefault=False)
New in version 3.8.
Copies the value hold by a property on an edge to another edge in this property.
- Parameters
edgeDst (
tlp.edge
) – the node to copy the value to.edgeSrc (
tlp.edge
) – the node to copy the value from.prop (
tlp.StringProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(prop)
New in version 3.8.
Copies the values hold by a property in this property.
- Parameters
prop (
tlp.StringProperty
) – the property to copy
- getNodesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all nodes belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all edges belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgeDefaultValue()¶
Returns the default value associated to the edges.
- Return type
string
- getEdgeValue(edge)¶
Returns the value associated to a particular edge.
- Parameters
edge (
tlp.edge
) – an existing edge- Return type
string
- Throws
an exception if the edge does not belong to the graph attached to the property
- getNodeDefaultValue()¶
Returns the default value associated to the nodes.
- Return type
string
- getNodeValue(node)¶
Returns the value associated to a particular node.
- Parameters
node (
tlp.node
) – an existing node- Return type
string
- Throws
an exception if the node does not belong to the graph attached to the property
- setAllEdgeValue(val)¶
Sets the same value for all edges. All previous values are lost and the given value is assigned as the default one to the future added edges.
- Parameters
val (string) – the value to set on the edges.
- setAllNodeValue(val)¶
Sets the same value for all nodes. All previous values are lost and the given value is assigned as the default one to the future added nodes.
- Parameters
val (string) – the value to set on the nodes.
- setValueToGraphNodes(val, graph)¶
New in version 5.0.
Sets the same value for all nodes in a graph. Only the nodes from that graph will have their value modified in the property and the default node value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property (including itself), no node value will be modified in it.
- Parameters
val (string) – the value to set on the nodes.
graph (
tlp.Graph
) – a graph that defines a set of nodes
- setValueToGraphEdges(val, graph)¶
New in version 5.0.
Sets the same value for all edges in a graph. Only the edges from that graph will have their value modified in the property and the default edge value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property (including itself), no node value will be modified in it.
- Parameters
val (string) – the value to set on the edges.
graph (
tlp.Graph
) – a graph that defines a set of edges
- setEdgeValue(edge, val)¶
Sets the value of a particular edge.
- Parameters
edge (
tlp.edge
) – an existing edgeval (string) – the value to set on the edge
- Throws
an exception if the edge does not belong to the graph attached to the property
- setNodeValue(node, val)¶
Sets the value of a particular node.
- Parameters
node (
tlp.node
) – an existing nodeval (string) – the value to set on the node
- Throws
an exception if the node does not belong to the graph attached to the property
- setNodeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added nodes.
- Parameters
val (string) – the new value to set on future added nodes.
- setEdgeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added edges.
- Parameters
val (string) – the new value to set on future added edges.
tlp.BooleanVectorProperty¶
- class tlp.BooleanVectorProperty¶
Bases:
tlp.PropertyInterface
- copy(nodeDst, nodeSrc, prop, ifNotDefault=False)¶
New in version 3.8.
Copies the value hold by a property on a node to another node in this property.
- Parameters
nodeDst (
tlp.node
) – the node to copy the value to.nodeSrc (
tlp.node
) – the node to copy the value from.prop (
tlp.BooleanVectorProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(edgeDst, edgeSrc, prop, ifNotDefault=False)
New in version 3.8.
Copies the value hold by a property on an edge to another edge in this property.
- Parameters
edgeDst (
tlp.edge
) – the node to copy the value to.edgeSrc (
tlp.edge
) – the node to copy the value from.prop (
tlp.BooleanVectorProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(prop)
New in version 3.8.
Copies the values hold by a property in this property.
- Parameters
prop (
tlp.BooleanVectorProperty
) – the property to copy
- getNodesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all nodes belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all edges belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgeDefaultValue()¶
Returns the default list of values associated to the edges.
- Return type
list of boolean
- getEdgeValue(edge)¶
Returns a copy of the list of values associated to a particular edge.
To add a new value k to the list associated to an edge e for a property prop, one has to write:
l = prop.getEdgeValue(e) # or prop[e] l.append(k) prop[e] = l #or prop.setEdgeValue(e, l)
- Parameters
edge (
tlp.edge
) – an existing edge- Return type
list of boolean
- Throws
an exception if the edge does not belong to the graph attached to the property
- getNodeDefaultValue()¶
Returns the default list of values associated to the nodes.
- Return type
list of boolean
- getNodeValue(node)¶
Returns a copy of the list of values associated to a particular node.
To add a new value k to the list associated to a node n for a property prop, one has to write:
l = prop.getNodeValue(n) # or prop[n] l.append(k) prop[n] = l # or prop.setNodeValue(n, l)
- Parameters
node (
tlp.node
) – an existing node- Return type
list of boolean
- Throws
an exception if the node does not belong to the graph attached to the property
- setAllEdgeValue(val)¶
Sets the same list of values for all edges. All previous values are lost and the given value is assigned as the default one to the future added edges.
- Parameters
val (list of boolean) – the list of values to set on the edges
- setAllNodeValue(val)¶
Sets the same list of values for all nodes. All previous values are lost and the given value is assigned as the default one to the future added nodes.
- Parameters
val (list of boolean) – the list of values to set on the nodes
- setValueToGraphNodes(val, graph)¶
New in version 5.0.
Sets the same list of values for all nodes in a graph. Only the nodes from that graph will have their value modified in the property and the default node value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property, no node value will be modified in it.
- Parameters
val (list of boolean) – the list of values to set on the nodes
graph (
tlp.Graph
) – a graph that defines a set of nodes
- setValueToGraphEdges(val, graph)¶
New in version 5.0.
Sets the same list of values for all edges in a graph. Only the edges from that graph will have their value modified in the property and the default edge value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property, no edge value will be modified in it.
- Parameters
val (list of boolean) – the list of values to set on the edges
graph (
tlp.Graph
) – a graph that defines a set of edges
- setEdgeValue(edge, val)¶
Sets the list of values of a particular edge.
- Parameters
edge (
tlp.edge
) – an existing edgeval (list of boolean) – the list of values to set on the edge
- Throws
an exception if the edge does not belong to the graph attached to the property
- setNodeValue(node, val)¶
Sets the list of values of a particular node.
- Parameters
node (
tlp.node
) – an existing nodeval (list of boolean) – the list of values to set on the node
- Throws
an exception if the node does not belong to the graph attached to the property
- setNodeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added nodes.
- Parameters
val (list of boolean) – the new value to set on future added nodes.
- setEdgeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added edges.
- Parameters
val (list of boolean) – the new value to set on future added edges.
- getNodeEltValue(node, index)¶
Returns the value in the list attached to a particular node at the given index.
- Parameters
node (
tlp.node
) – an existing nodeindex (integer) – the index in the list
- Return type
boolean
- Throws
an exception if the node does not belong to the graph attached to the property or if the list attached to the node has a size smaller than the given index.
- setNodeEltValue(node, index, val)¶
Sets the value in the list attached to a particular node at the given index.
- Parameters
node (
tlp.node
) – an existing nodeindex (integer) – the index in the list
val (boolean) – the value to set in the list
- Throws
an exception if the node does not belong to the graph attached to the property or if the list attached to the node has a size smaller than the given index.
- pushBackNodeEltValue(node, val)¶
Inserts a value at the end of the list attached to a particular node. The size of the list is incremented by one.
- Parameters
node (
tlp.node
) – an existing nodeval (boolean) – the value to add in the list
- Throws
an exception if the node does not belong to the graph attached to the property
- popBackNodeEltValue(node)¶
Removes the value at the end of the list (if not empty) attached to a particular node. The size of the list is decremented by one.
- Parameters
node (
tlp.node
) – an existing node- Throws
an exception if the node does not belong to the graph attached to the property
- resizeNodeValue(node, size)¶
Resizes the list attached to a particular node. A default value will be assigned to new elements (if any).
- Parameters
node (
tlp.node
) – an existing nodesize (integer) – the new size of the list
- Throws
an exception if the node does not belong to the graph attached to the property
- resizeNodeValue(node, size, val)
Resizes the list attached to a particular node. The value given in parameter will be assigned to new elements (if any).
- Parameters
node (
tlp.node
) – an existing nodesize (integer) – the new size of the list
val (boolean) – the value to assign on new elements in the list
- Throws
an exception if the node does not belong to the graph attached to the property
- getEdgeEltValue(edge, index)¶
Returns the value in the list attached to a particular edge at the given index.
- Parameters
edge (
tlp.edge
) – an existing edgeindex (integer) – the index in the list
- Return type
boolean
- Throws
an exception if the edge does not belong to the graph attached to the property or if the list attached to the edge has a size smaller than the given index.
- setEdgeEltValue(edge, index, val)¶
Sets the value in the list attached to a particular edge at the given index.
- Parameters
edge (
tlp.edge
) – an existing edgeindex (integer) – the index in the list
val (boolean) – the value to set in the list
- Throws
an exception if the edge does not belong to the graph attached to the property or if the list attached to the edge has a size smaller than the given index.
- pushBackEdgeEltValue(edge, val)¶
Inserts a value at the end of the list attached to a particular edge. The size of the list is incremented by one.
- Parameters
edge (
tlp.edge
) – an existing edgeval (boolean) – the value to add in the list
- Throws
an exception if the edge does not belong to the graph attached to the property
- popBackEdgeEltValue(edge)¶
Removes the value at the end of the list (if not empty) attached to a particular edge. The size of the list is decremented by one.
- Parameters
edge (
tlp.edge
) – an existing edge- Throws
an exception if the edge does not belong to the graph attached to the property
- resizeEdgeValue(edge, size)¶
Resizes the list attached to a particular edge. A default value will be assigned to new elements (if any).
- Parameters
edge (
tlp.edge
) – an existing edgesize (integer) – the new size of the list
- Throws
an exception if the edge does not belong to the graph attached to the property
- resizeEdgeValue(edge, size, val)
Resizes the list attached to a particular edge. The value given in parameter will be assigned to new elements (if any).
- Parameters
edge (
tlp.edge
) – an existing edgesize (integer) – the new size of the list
val (boolean) – the value to assign on new elements in the list
- Throws
an exception if the node does not belong to the graph attached to the property
tlp.CoordVectorProperty¶
- class tlp.CoordVectorProperty¶
Bases:
tlp.PropertyInterface
- copy(nodeDst, nodeSrc, prop, ifNotDefault=False)¶
New in version 3.8.
Copies the value hold by a property on a node to another node in this property.
- Parameters
nodeDst (
tlp.node
) – the node to copy the value to.nodeSrc (
tlp.node
) – the node to copy the value from.prop (
tlp.CoordVectorProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(edgeDst, edgeSrc, prop, ifNotDefault=False)
New in version 3.8.
Copies the value hold by a property on an edge to another edge in this property.
- Parameters
edgeDst (
tlp.edge
) – the node to copy the value to.edgeSrc (
tlp.edge
) – the node to copy the value from.prop (
tlp.CoordVectorProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(prop)
New in version 3.8.
Copies the values hold by a property in this property.
- Parameters
prop (
tlp.CoordVectorProperty
) – the property to copy
- getNodesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all nodes belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all edges belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgeDefaultValue()¶
Returns the default list of values associated to the edges.
- Return type
list of
tlp.Coord
- getEdgeValue(edge)¶
Returns a copy of the list of values associated to a particular edge.
To add a new value k to the list associated to an edge e for a property prop, one has to write:
l = prop.getEdgeValue(e) # or prop[e] l.append(k) prop[e] = l #or prop.setEdgeValue(e, l)
- getNodeDefaultValue()¶
Returns the default list of values associated to the nodes.
- Return type
list of
tlp.Coord
- getNodeValue(node)¶
Returns a copy of the list of values associated to a particular node.
To add a new value k to the list associated to a node n for a property prop, one has to write:
l = prop.getNodeValue(n) # or prop[n] l.append(k) prop[n] = l # or prop.setNodeValue(n, l)
- setAllEdgeValue(val)¶
Sets the same list of values for all edges. All previous values are lost and the given value is assigned as the default one to the future added edges.
- Parameters
val (list of
tlp.Coord
) – the list of values to set on the edges
- setAllNodeValue(val)¶
Sets the same list of values for all nodes. All previous values are lost and the given value is assigned as the default one to the future added nodes.
- Parameters
val (list of
tlp.Coord
) – the list of values to set on the nodes
- setValueToGraphNodes(val, graph)¶
New in version 5.0.
Sets the same list of values for all nodes in a graph. Only the nodes from that graph will have their value modified in the property and the default node value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property, no node value will be modified in it.
- setValueToGraphEdges(val, graph)¶
New in version 5.0.
Sets the same list of values for all edges in a graph. Only the edges from that graph will have their value modified in the property and the default edge value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property, no edge value will be modified in it.
- setEdgeValue(edge, val)¶
Sets the list of values of a particular edge.
- setNodeValue(node, val)¶
Sets the list of values of a particular node.
- setNodeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added nodes.
- Parameters
val (list of
tlp.Coord
) – the new value to set on future added nodes.
- setEdgeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added edges.
- Parameters
val (list of
tlp.Coord
) – the new value to set on future added edges.
- getNodeEltValue(node, index)¶
Returns the value in the list attached to a particular node at the given index.
- setNodeEltValue(node, index, val)¶
Sets the value in the list attached to a particular node at the given index.
- pushBackNodeEltValue(node, val)¶
Inserts a value at the end of the list attached to a particular node. The size of the list is incremented by one.
- popBackNodeEltValue(node)¶
Removes the value at the end of the list (if not empty) attached to a particular node. The size of the list is decremented by one.
- Parameters
node (
tlp.node
) – an existing node- Throws
an exception if the node does not belong to the graph attached to the property
- resizeNodeValue(node, size)¶
Resizes the list attached to a particular node. A default value will be assigned to new elements (if any).
- Parameters
node (
tlp.node
) – an existing nodesize (integer) – the new size of the list
- Throws
an exception if the node does not belong to the graph attached to the property
- resizeNodeValue(node, size, val)
Resizes the list attached to a particular node. The value given in parameter will be assigned to new elements (if any).
- getEdgeEltValue(edge, index)¶
Returns the value in the list attached to a particular edge at the given index.
- setEdgeEltValue(edge, index, val)¶
Sets the value in the list attached to a particular edge at the given index.
- pushBackEdgeEltValue(edge, val)¶
Inserts a value at the end of the list attached to a particular edge. The size of the list is incremented by one.
- popBackEdgeEltValue(edge)¶
Removes the value at the end of the list (if not empty) attached to a particular edge. The size of the list is decremented by one.
- Parameters
edge (
tlp.edge
) – an existing edge- Throws
an exception if the edge does not belong to the graph attached to the property
- resizeEdgeValue(edge, size)¶
Resizes the list attached to a particular edge. A default value will be assigned to new elements (if any).
- Parameters
edge (
tlp.edge
) – an existing edgesize (integer) – the new size of the list
- Throws
an exception if the edge does not belong to the graph attached to the property
- resizeEdgeValue(edge, size, val)
Resizes the list attached to a particular edge. The value given in parameter will be assigned to new elements (if any).
tlp.ColorVectorProperty¶
- class tlp.ColorVectorProperty¶
Bases:
tlp.PropertyInterface
- copy(nodeDst, nodeSrc, prop, ifNotDefault=False)¶
New in version 3.8.
Copies the value hold by a property on a node to another node in this property.
- Parameters
nodeDst (
tlp.node
) – the node to copy the value to.nodeSrc (
tlp.node
) – the node to copy the value from.prop (
tlp.ColorVectorProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(edgeDst, edgeSrc, prop, ifNotDefault=False)
New in version 3.8.
Copies the value hold by a property on an edge to another edge in this property.
- Parameters
edgeDst (
tlp.edge
) – the node to copy the value to.edgeSrc (
tlp.edge
) – the node to copy the value from.prop (
tlp.ColorVectorProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(prop)
New in version 3.8.
Copies the values hold by a property in this property.
- Parameters
prop (
tlp.ColorVectorProperty
) – the property to copy
- getNodesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all nodes belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all edges belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgeDefaultValue()¶
Returns the default list of values associated to the edges.
- Return type
list of
tlp.Color
- getEdgeValue(edge)¶
Returns a copy of the list of values associated to a particular edge.
To add a new value k to the list associated to an edge e for a property prop, one has to write:
l = prop.getEdgeValue(e) # or prop[e] l.append(k) prop[e] = l #or prop.setEdgeValue(e, l)
- getNodeDefaultValue()¶
Returns the default list of values associated to the nodes.
- Return type
list of
tlp.Color
- getNodeValue(node)¶
Returns a copy of the list of values associated to a particular node.
To add a new value k to the list associated to a node n for a property prop, one has to write:
l = prop.getNodeValue(n) # or prop[n] l.append(k) prop[n] = l # or prop.setNodeValue(n, l)
- setAllEdgeValue(val)¶
Sets the same list of values for all edges. All previous values are lost and the given value is assigned as the default one to the future added edges.
- Parameters
val (list of
tlp.Color
) – the list of values to set on the edges
- setAllNodeValue(val)¶
Sets the same list of values for all nodes. All previous values are lost and the given value is assigned as the default one to the future added nodes.
- Parameters
val (list of
tlp.Color
) – the list of values to set on the nodes
- setValueToGraphNodes(val, graph)¶
New in version 5.0.
Sets the same list of values for all nodes in a graph. Only the nodes from that graph will have their value modified in the property and the default node value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property, no node value will be modified in it.
- setValueToGraphEdges(val, graph)¶
New in version 5.0.
Sets the same list of values for all edges in a graph. Only the edges from that graph will have their value modified in the property and the default edge value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property, no edge value will be modified in it.
- setEdgeValue(edge, val)¶
Sets the list of values of a particular edge.
- setNodeValue(node, val)¶
Sets the list of values of a particular node.
- setNodeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added nodes.
- Parameters
val (list of
tlp.Color
) – the new value to set on future added nodes.
- setEdgeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added edges.
- Parameters
val (list of
tlp.Color
) – the new value to set on future added edges.
- getNodeEltValue(node, index)¶
Returns the value in the list attached to a particular node at the given index.
- setNodeEltValue(node, index, val)¶
Sets the value in the list attached to a particular node at the given index.
- pushBackNodeEltValue(node, val)¶
Inserts a value at the end of the list attached to a particular node. The size of the list is incremented by one.
- popBackNodeEltValue(node)¶
Removes the value at the end of the list (if not empty) attached to a particular node. The size of the list is decremented by one.
- Parameters
node (
tlp.node
) – an existing node- Throws
an exception if the node does not belong to the graph attached to the property
- resizeNodeValue(node, size)¶
Resizes the list attached to a particular node. A default value will be assigned to new elements (if any).
- Parameters
node (
tlp.node
) – an existing nodesize (integer) – the new size of the list
- Throws
an exception if the node does not belong to the graph attached to the property
- resizeNodeValue(node, size, val)
Resizes the list attached to a particular node. The value given in parameter will be assigned to new elements (if any).
- getEdgeEltValue(edge, index)¶
Returns the value in the list attached to a particular edge at the given index.
- setEdgeEltValue(edge, index, val)¶
Sets the value in the list attached to a particular edge at the given index.
- pushBackEdgeEltValue(edge, val)¶
Inserts a value at the end of the list attached to a particular edge. The size of the list is incremented by one.
- popBackEdgeEltValue(edge)¶
Removes the value at the end of the list (if not empty) attached to a particular edge. The size of the list is decremented by one.
- Parameters
edge (
tlp.edge
) – an existing edge- Throws
an exception if the edge does not belong to the graph attached to the property
- resizeEdgeValue(edge, size)¶
Resizes the list attached to a particular edge. A default value will be assigned to new elements (if any).
- Parameters
edge (
tlp.edge
) – an existing edgesize (integer) – the new size of the list
- Throws
an exception if the edge does not belong to the graph attached to the property
- resizeEdgeValue(edge, size, val)
Resizes the list attached to a particular edge. The value given in parameter will be assigned to new elements (if any).
tlp.DoubleVectorProperty¶
- class tlp.DoubleVectorProperty¶
Bases:
tlp.PropertyInterface
- copy(nodeDst, nodeSrc, prop, ifNotDefault=False)¶
New in version 3.8.
Copies the value hold by a property on a node to another node in this property.
- Parameters
nodeDst (
tlp.node
) – the node to copy the value to.nodeSrc (
tlp.node
) – the node to copy the value from.prop (
tlp.DoubleVectorProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(edgeDst, edgeSrc, prop, ifNotDefault=False)
New in version 3.8.
Copies the value hold by a property on an edge to another edge in this property.
- Parameters
edgeDst (
tlp.edge
) – the node to copy the value to.edgeSrc (
tlp.edge
) – the node to copy the value from.prop (
tlp.DoubleVectorProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(prop)
New in version 3.8.
Copies the values hold by a property in this property.
- Parameters
prop (
tlp.DoubleVectorProperty
) – the property to copy
- getNodesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all nodes belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all edges belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgeDefaultValue()¶
Returns the default list of values associated to the edges.
- Return type
list of float
- getEdgeValue(edge)¶
Returns a copy of the list of values associated to a particular edge.
To add a new value k to the list associated to an edge e for a property prop, one has to write:
l = prop.getEdgeValue(e) # or prop[e] l.append(k) prop[e] = l #or prop.setEdgeValue(e, l)
- Parameters
edge (
tlp.edge
) – an existing edge- Return type
list of float
- Throws
an exception if the edge does not belong to the graph attached to the property
- getNodeDefaultValue()¶
Returns the default list of values associated to the nodes.
- Return type
list of float
- getNodeValue(node)¶
Returns a copy of the list of values associated to a particular node.
To add a new value k to the list associated to a node n for a property prop, one has to write:
l = prop.getNodeValue(n) # or prop[n] l.append(k) prop[n] = l # or prop.setNodeValue(n, l)
- Parameters
node (
tlp.node
) – an existing node- Return type
list of float
- Throws
an exception if the node does not belong to the graph attached to the property
- setAllEdgeValue(val)¶
Sets the same list of values for all edges. All previous values are lost and the given value is assigned as the default one to the future added edges.
- Parameters
val (list of float) – the list of values to set on the edges
- setAllNodeValue(val)¶
Sets the same list of values for all nodes. All previous values are lost and the given value is assigned as the default one to the future added nodes.
- Parameters
val (list of float) – the list of values to set on the nodes
- setValueToGraphNodes(val, graph)¶
New in version 5.0.
Sets the same list of values for all nodes in a graph. Only the nodes from that graph will have their value modified in the property and the default node value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property, no node value will be modified in it.
- Parameters
val (list of float) – the list of values to set on the nodes
graph (
tlp.Graph
) – a graph that defines a set of nodes
- setValueToGraphEdges(val, graph)¶
New in version 5.0.
Sets the same list of values for all edges in a graph. Only the edges from that graph will have their value modified in the property and the default edge value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property, no edge value will be modified in it.
- Parameters
val (list of float) – the list of values to set on the edges
graph (
tlp.Graph
) – a graph that defines a set of edges
- setEdgeValue(edge, val)¶
Sets the list of values of a particular edge.
- Parameters
edge (
tlp.edge
) – an existing edgeval (list of float) – the list of values to set on the edge
- Throws
an exception if the edge does not belong to the graph attached to the property
- setNodeValue(node, val)¶
Sets the list of values of a particular node.
- Parameters
node (
tlp.node
) – an existing nodeval (list of float) – the list of values to set on the node
- Throws
an exception if the node does not belong to the graph attached to the property
- setNodeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added nodes.
- Parameters
val (list of float) – the new value to set on future added nodes.
- setEdgeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added edges.
- Parameters
val (list of float) – the new value to set on future added edges.
- getNodeEltValue(node, index)¶
Returns the value in the list attached to a particular node at the given index.
- Parameters
node (
tlp.node
) – an existing nodeindex (integer) – the index in the list
- Return type
float
- Throws
an exception if the node does not belong to the graph attached to the property or if the list attached to the node has a size smaller than the given index.
- setNodeEltValue(node, index, val)¶
Sets the value in the list attached to a particular node at the given index.
- Parameters
node (
tlp.node
) – an existing nodeindex (integer) – the index in the list
val (float) – the value to set in the list
- Throws
an exception if the node does not belong to the graph attached to the property or if the list attached to the node has a size smaller than the given index.
- pushBackNodeEltValue(node, val)¶
Inserts a value at the end of the list attached to a particular node. The size of the list is incremented by one.
- Parameters
node (
tlp.node
) – an existing nodeval (float) – the value to add in the list
- Throws
an exception if the node does not belong to the graph attached to the property
- popBackNodeEltValue(node)¶
Removes the value at the end of the list (if not empty) attached to a particular node. The size of the list is decremented by one.
- Parameters
node (
tlp.node
) – an existing node- Throws
an exception if the node does not belong to the graph attached to the property
- resizeNodeValue(node, size)¶
Resizes the list attached to a particular node. A default value will be assigned to new elements (if any).
- Parameters
node (
tlp.node
) – an existing nodesize (integer) – the new size of the list
- Throws
an exception if the node does not belong to the graph attached to the property
- resizeNodeValue(node, size, val)
Resizes the list attached to a particular node. The value given in parameter will be assigned to new elements (if any).
- Parameters
node (
tlp.node
) – an existing nodesize (integer) – the new size of the list
val (float) – the value to assign on new elements in the list
- Throws
an exception if the node does not belong to the graph attached to the property
- getEdgeEltValue(edge, index)¶
Returns the value in the list attached to a particular edge at the given index.
- Parameters
edge (
tlp.edge
) – an existing edgeindex (integer) – the index in the list
- Return type
float
- Throws
an exception if the edge does not belong to the graph attached to the property or if the list attached to the edge has a size smaller than the given index.
- setEdgeEltValue(edge, index, val)¶
Sets the value in the list attached to a particular edge at the given index.
- Parameters
edge (
tlp.edge
) – an existing edgeindex (integer) – the index in the list
val (float) – the value to set in the list
- Throws
an exception if the edge does not belong to the graph attached to the property or if the list attached to the edge has a size smaller than the given index.
- pushBackEdgeEltValue(edge, val)¶
Inserts a value at the end of the list attached to a particular edge. The size of the list is incremented by one.
- Parameters
edge (
tlp.edge
) – an existing edgeval (float) – the value to add in the list
- Throws
an exception if the edge does not belong to the graph attached to the property
- popBackEdgeEltValue(edge)¶
Removes the value at the end of the list (if not empty) attached to a particular edge. The size of the list is decremented by one.
- Parameters
edge (
tlp.edge
) – an existing edge- Throws
an exception if the edge does not belong to the graph attached to the property
- resizeEdgeValue(edge, size)¶
Resizes the list attached to a particular edge. A default value will be assigned to new elements (if any).
- Parameters
edge (
tlp.edge
) – an existing edgesize (integer) – the new size of the list
- Throws
an exception if the edge does not belong to the graph attached to the property
- resizeEdgeValue(edge, size, val)
Resizes the list attached to a particular edge. The value given in parameter will be assigned to new elements (if any).
- Parameters
edge (
tlp.edge
) – an existing edgesize (integer) – the new size of the list
val (float) – the value to assign on new elements in the list
- Throws
an exception if the node does not belong to the graph attached to the property
tlp.IntegerVectorProperty¶
- class tlp.IntegerVectorProperty¶
Bases:
tlp.PropertyInterface
- copy(nodeDst, nodeSrc, prop, ifNotDefault=False)¶
New in version 3.8.
Copies the value hold by a property on a node to another node in this property.
- Parameters
nodeDst (
tlp.node
) – the node to copy the value to.nodeSrc (
tlp.node
) – the node to copy the value from.prop (
tlp.IntegerVectorProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(edgeDst, edgeSrc, prop, ifNotDefault=False)
New in version 3.8.
Copies the value hold by a property on an edge to another edge in this property.
- Parameters
edgeDst (
tlp.edge
) – the node to copy the value to.edgeSrc (
tlp.edge
) – the node to copy the value from.prop (
tlp.IntegerVectorProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(prop)
New in version 3.8.
Copies the values hold by a property in this property.
- Parameters
prop (
tlp.IntegerVectorProperty
) – the property to copy
- getNodesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all nodes belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all edges belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgeDefaultValue()¶
Returns the default list of values associated to the edges.
- Return type
list of integer
- getEdgeValue(edge)¶
Returns a copy of the list of values associated to a particular edge.
To add a new value k to the list associated to an edge e for a property prop, one has to write:
l = prop.getEdgeValue(e) # or prop[e] l.append(k) prop[e] = l #or prop.setEdgeValue(e, l)
- Parameters
edge (
tlp.edge
) – an existing edge- Return type
list of integer
- Throws
an exception if the edge does not belong to the graph attached to the property
- getNodeDefaultValue()¶
Returns the default list of values associated to the nodes.
- Return type
list of integer
- getNodeValue(node)¶
Returns a copy of the list of values associated to a particular node.
To add a new value k to the list associated to a node n for a property prop, one has to write:
l = prop.getNodeValue(n) # or prop[n] l.append(k) prop[n] = l # or prop.setNodeValue(n, l)
- Parameters
node (
tlp.node
) – an existing node- Return type
list of integer
- Throws
an exception if the node does not belong to the graph attached to the property
- setAllEdgeValue(val)¶
Sets the same list of values for all edges. All previous values are lost and the given value is assigned as the default one to the future added edges.
- Parameters
val (list of integer) – the list of values to set on the edges
- setAllNodeValue(val)¶
Sets the same list of values for all nodes. All previous values are lost and the given value is assigned as the default one to the future added nodes.
- Parameters
val (list of integer) – the list of values to set on the nodes
- setValueToGraphNodes(val, graph)¶
New in version 5.0.
Sets the same list of values for all nodes in a graph. Only the nodes from that graph will have their value modified in the property and the default node value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property, no node value will be modified in it.
- Parameters
val (list of integer) – the list of values to set on the nodes
graph (
tlp.Graph
) – a graph that defines a set of nodes
- setValueToGraphEdges(val, graph)¶
New in version 5.0.
Sets the same list of values for all edges in a graph. Only the edges from that graph will have their value modified in the property and the default edge value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property, no edge value will be modified in it.
- Parameters
val (list of integer) – the list of values to set on the edges
graph (
tlp.Graph
) – a graph that defines a set of edges
- setEdgeValue(edge, val)¶
Sets the list of values of a particular edge.
- Parameters
edge (
tlp.edge
) – an existing edgeval (list of integer) – the list of values to set on the edge
- Throws
an exception if the edge does not belong to the graph attached to the property
- setNodeValue(node, val)¶
Sets the list of values of a particular node.
- Parameters
node (
tlp.node
) – an existing nodeval (list of integer) – the list of values to set on the node
- Throws
an exception if the node does not belong to the graph attached to the property
- setNodeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added nodes.
- Parameters
val (list of integer) – the new value to set on future added nodes.
- setEdgeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added edges.
- Parameters
val (list of integer) – the new value to set on future added edges.
- getNodeEltValue(node, index)¶
Returns the value in the list attached to a particular node at the given index.
- Parameters
node (
tlp.node
) – an existing nodeindex (integer) – the index in the list
- Return type
integer
- Throws
an exception if the node does not belong to the graph attached to the property or if the list attached to the node has a size smaller than the given index.
- setNodeEltValue(node, index, val)¶
Sets the value in the list attached to a particular node at the given index.
- Parameters
node (
tlp.node
) – an existing nodeindex (integer) – the index in the list
val (integer) – the value to set in the list
- Throws
an exception if the node does not belong to the graph attached to the property or if the list attached to the node has a size smaller than the given index.
- pushBackNodeEltValue(node, val)¶
Inserts a value at the end of the list attached to a particular node. The size of the list is incremented by one.
- Parameters
node (
tlp.node
) – an existing nodeval (integer) – the value to add in the list
- Throws
an exception if the node does not belong to the graph attached to the property
- popBackNodeEltValue(node)¶
Removes the value at the end of the list (if not empty) attached to a particular node. The size of the list is decremented by one.
- Parameters
node (
tlp.node
) – an existing node- Throws
an exception if the node does not belong to the graph attached to the property
- resizeNodeValue(node, size)¶
Resizes the list attached to a particular node. A default value will be assigned to new elements (if any).
- Parameters
node (
tlp.node
) – an existing nodesize (integer) – the new size of the list
- Throws
an exception if the node does not belong to the graph attached to the property
- resizeNodeValue(node, size, val)
Resizes the list attached to a particular node. The value given in parameter will be assigned to new elements (if any).
- Parameters
node (
tlp.node
) – an existing nodesize (integer) – the new size of the list
val (integer) – the value to assign on new elements in the list
- Throws
an exception if the node does not belong to the graph attached to the property
- getEdgeEltValue(edge, index)¶
Returns the value in the list attached to a particular edge at the given index.
- Parameters
edge (
tlp.edge
) – an existing edgeindex (integer) – the index in the list
- Return type
integer
- Throws
an exception if the edge does not belong to the graph attached to the property or if the list attached to the edge has a size smaller than the given index.
- setEdgeEltValue(edge, index, val)¶
Sets the value in the list attached to a particular edge at the given index.
- Parameters
edge (
tlp.edge
) – an existing edgeindex (integer) – the index in the list
val (integer) – the value to set in the list
- Throws
an exception if the edge does not belong to the graph attached to the property or if the list attached to the edge has a size smaller than the given index.
- pushBackEdgeEltValue(edge, val)¶
Inserts a value at the end of the list attached to a particular edge. The size of the list is incremented by one.
- Parameters
edge (
tlp.edge
) – an existing edgeval (integer) – the value to add in the list
- Throws
an exception if the edge does not belong to the graph attached to the property
- popBackEdgeEltValue(edge)¶
Removes the value at the end of the list (if not empty) attached to a particular edge. The size of the list is decremented by one.
- Parameters
edge (
tlp.edge
) – an existing edge- Throws
an exception if the edge does not belong to the graph attached to the property
- resizeEdgeValue(edge, size)¶
Resizes the list attached to a particular edge. A default value will be assigned to new elements (if any).
- Parameters
edge (
tlp.edge
) – an existing edgesize (integer) – the new size of the list
- Throws
an exception if the edge does not belong to the graph attached to the property
- resizeEdgeValue(edge, size, val)
Resizes the list attached to a particular edge. The value given in parameter will be assigned to new elements (if any).
- Parameters
edge (
tlp.edge
) – an existing edgesize (integer) – the new size of the list
val (integer) – the value to assign on new elements in the list
- Throws
an exception if the node does not belong to the graph attached to the property
tlp.SizeVectorProperty¶
- class tlp.SizeVectorProperty¶
Bases:
tlp.PropertyInterface
- copy(nodeDst, nodeSrc, prop, ifNotDefault=False)¶
New in version 3.8.
Copies the value hold by a property on a node to another node in this property.
- Parameters
nodeDst (
tlp.node
) – the node to copy the value to.nodeSrc (
tlp.node
) – the node to copy the value from.prop (
tlp.SizeVectorProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(edgeDst, edgeSrc, prop, ifNotDefault=False)
New in version 3.8.
Copies the value hold by a property on an edge to another edge in this property.
- Parameters
edgeDst (
tlp.edge
) – the node to copy the value to.edgeSrc (
tlp.edge
) – the node to copy the value from.prop (
tlp.SizeVectorProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(prop)
New in version 3.8.
Copies the values hold by a property in this property.
- Parameters
prop (
tlp.SizeVectorProperty
) – the property to copy
- getNodesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all nodes belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all edges belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgeDefaultValue()¶
Returns the default list of values associated to the edges.
- Return type
list of
tlp.Size
- getEdgeValue(edge)¶
Returns a copy of the list of values associated to a particular edge.
To add a new value k to the list associated to an edge e for a property prop, one has to write:
l = prop.getEdgeValue(e) # or prop[e] l.append(k) prop[e] = l #or prop.setEdgeValue(e, l)
- getNodeDefaultValue()¶
Returns the default list of values associated to the nodes.
- Return type
list of
tlp.Size
- getNodeValue(node)¶
Returns a copy of the list of values associated to a particular node.
To add a new value k to the list associated to a node n for a property prop, one has to write:
l = prop.getNodeValue(n) # or prop[n] l.append(k) prop[n] = l # or prop.setNodeValue(n, l)
- setAllEdgeValue(val)¶
Sets the same list of values for all edges. All previous values are lost and the given value is assigned as the default one to the future added edges.
- Parameters
val (list of
tlp.Size
) – the list of values to set on the edges
- setAllNodeValue(val)¶
Sets the same list of values for all nodes. All previous values are lost and the given value is assigned as the default one to the future added nodes.
- Parameters
val (list of
tlp.Size
) – the list of values to set on the nodes
- setValueToGraphNodes(val, graph)¶
New in version 5.0.
Sets the same list of values for all nodes in a graph. Only the nodes from that graph will have their value modified in the property and the default node value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property, no node value will be modified in it.
- setValueToGraphEdges(val, graph)¶
New in version 5.0.
Sets the same list of values for all edges in a graph. Only the edges from that graph will have their value modified in the property and the default edge value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property, no edge value will be modified in it.
- setEdgeValue(edge, val)¶
Sets the list of values of a particular edge.
- setNodeValue(node, val)¶
Sets the list of values of a particular node.
- setNodeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added nodes.
- Parameters
val (list of
tlp.Size
) – the new value to set on future added nodes.
- setEdgeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added edges.
- Parameters
val (list of
tlp.Size
) – the new value to set on future added edges.
- getNodeEltValue(node, index)¶
Returns the value in the list attached to a particular node at the given index.
- setNodeEltValue(node, index, val)¶
Sets the value in the list attached to a particular node at the given index.
- pushBackNodeEltValue(node, val)¶
Inserts a value at the end of the list attached to a particular node. The size of the list is incremented by one.
- popBackNodeEltValue(node)¶
Removes the value at the end of the list (if not empty) attached to a particular node. The size of the list is decremented by one.
- Parameters
node (
tlp.node
) – an existing node- Throws
an exception if the node does not belong to the graph attached to the property
- resizeNodeValue(node, size)¶
Resizes the list attached to a particular node. A default value will be assigned to new elements (if any).
- Parameters
node (
tlp.node
) – an existing nodesize (integer) – the new size of the list
- Throws
an exception if the node does not belong to the graph attached to the property
- resizeNodeValue(node, size, val)
Resizes the list attached to a particular node. The value given in parameter will be assigned to new elements (if any).
- getEdgeEltValue(edge, index)¶
Returns the value in the list attached to a particular edge at the given index.
- setEdgeEltValue(edge, index, val)¶
Sets the value in the list attached to a particular edge at the given index.
- pushBackEdgeEltValue(edge, val)¶
Inserts a value at the end of the list attached to a particular edge. The size of the list is incremented by one.
- popBackEdgeEltValue(edge)¶
Removes the value at the end of the list (if not empty) attached to a particular edge. The size of the list is decremented by one.
- Parameters
edge (
tlp.edge
) – an existing edge- Throws
an exception if the edge does not belong to the graph attached to the property
- resizeEdgeValue(edge, size)¶
Resizes the list attached to a particular edge. A default value will be assigned to new elements (if any).
- Parameters
edge (
tlp.edge
) – an existing edgesize (integer) – the new size of the list
- Throws
an exception if the edge does not belong to the graph attached to the property
- resizeEdgeValue(edge, size, val)
Resizes the list attached to a particular edge. The value given in parameter will be assigned to new elements (if any).
tlp.StringVectorProperty¶
- class tlp.StringVectorProperty¶
Bases:
tlp.PropertyInterface
- copy(nodeDst, nodeSrc, prop, ifNotDefault=False)¶
New in version 3.8.
Copies the value hold by a property on a node to another node in this property.
- Parameters
nodeDst (
tlp.node
) – the node to copy the value to.nodeSrc (
tlp.node
) – the node to copy the value from.prop (
tlp.StringVectorProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(edgeDst, edgeSrc, prop, ifNotDefault=False)
New in version 3.8.
Copies the value hold by a property on an edge to another edge in this property.
- Parameters
edgeDst (
tlp.edge
) – the node to copy the value to.edgeSrc (
tlp.edge
) – the node to copy the value from.prop (
tlp.StringVectorProperty
) – the property holding the value to copy.ifNotDefault (boolean) – whether to ignore default-valuated nodes or not. Defaults to
False
.
- copy(prop)
New in version 3.8.
Copies the values hold by a property in this property.
- Parameters
prop (
tlp.StringVectorProperty
) – the property to copy
- getNodesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all nodes belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgesEqualTo(val, graph=None)¶
New in version 5.0.
Returns an iterator through all edges belonging to the attached graph whose associated value is equal to the one given in parameter.
- getEdgeDefaultValue()¶
Returns the default list of values associated to the edges.
- Return type
list of string
- getEdgeValue(edge)¶
Returns a copy of the list of values associated to a particular edge.
To add a new value k to the list associated to an edge e for a property prop, one has to write:
l = prop.getEdgeValue(e) # or prop[e] l.append(k) prop[e] = l #or prop.setEdgeValue(e, l)
- Parameters
edge (
tlp.edge
) – an existing edge- Return type
list of string
- Throws
an exception if the edge does not belong to the graph attached to the property
- getNodeDefaultValue()¶
Returns the default list of values associated to the nodes.
- Return type
list of string
- getNodeValue(node)¶
Returns a copy of the list of values associated to a particular node.
To add a new value k to the list associated to a node n for a property prop, one has to write:
l = prop.getNodeValue(n) # or prop[n] l.append(k) prop[n] = l # or prop.setNodeValue(n, l)
- Parameters
node (
tlp.node
) – an existing node- Return type
list of string
- Throws
an exception if the node does not belong to the graph attached to the property
- setAllEdgeValue(val)¶
Sets the same list of values for all edges. All previous values are lost and the given value is assigned as the default one to the future added edges.
- Parameters
val (list of string) – the list of values to set on the edges
- setAllNodeValue(val)¶
Sets the same list of values for all nodes. All previous values are lost and the given value is assigned as the default one to the future added nodes.
- Parameters
val (list of string) – the list of values to set on the nodes
- setValueToGraphNodes(val, graph)¶
New in version 5.0.
Sets the same list of values for all nodes in a graph. Only the nodes from that graph will have their value modified in the property and the default node value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property, no node value will be modified in it.
- Parameters
val (list of string) – the list of values to set on the nodes
graph (
tlp.Graph
) – a graph that defines a set of nodes
- setValueToGraphEdges(val, graph)¶
New in version 5.0.
Sets the same list of values for all edges in a graph. Only the edges from that graph will have their value modified in the property and the default edge value will not be modified.
Warning
If the provided graph is not a descendant of the one associated to that property, no edge value will be modified in it.
- Parameters
val (list of string) – the list of values to set on the edges
graph (
tlp.Graph
) – a graph that defines a set of edges
- setEdgeValue(edge, val)¶
Sets the list of values of a particular edge.
- Parameters
edge (
tlp.edge
) – an existing edgeval (list of string) – the list of values to set on the edge
- Throws
an exception if the edge does not belong to the graph attached to the property
- setNodeValue(node, val)¶
Sets the list of values of a particular node.
- Parameters
node (
tlp.node
) – an existing nodeval (list of string) – the list of values to set on the node
- Throws
an exception if the node does not belong to the graph attached to the property
- setNodeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added nodes.
- Parameters
val (list of string) – the new value to set on future added nodes.
- setEdgeDefaultValue(val)¶
New in version 5.0.
Sets the value assigned as the default one to the future added edges.
- Parameters
val (list of string) – the new value to set on future added edges.
- getNodeEltValue(node, index)¶
Returns the value in the list attached to a particular node at the given index.
- Parameters
node (
tlp.node
) – an existing nodeindex (integer) – the index in the list
- Return type
string
- Throws
an exception if the node does not belong to the graph attached to the property or if the list attached to the node has a size smaller than the given index.
- setNodeEltValue(node, index, val)¶
Sets the value in the list attached to a particular node at the given index.
- Parameters
node (
tlp.node
) – an existing nodeindex (integer) – the index in the list
val (string) – the value to set in the list
- Throws
an exception if the node does not belong to the graph attached to the property or if the list attached to the node has a size smaller than the given index.
- pushBackNodeEltValue(node, val)¶
Inserts a value at the end of the list attached to a particular node. The size of the list is incremented by one.
- Parameters
node (
tlp.node
) – an existing nodeval (string) – the value to add in the list
- Throws
an exception if the node does not belong to the graph attached to the property
- popBackNodeEltValue(node)¶
Removes the value at the end of the list (if not empty) attached to a particular node. The size of the list is decremented by one.
- Parameters
node (
tlp.node
) – an existing node- Throws
an exception if the node does not belong to the graph attached to the property
- resizeNodeValue(node, size)¶
Resizes the list attached to a particular node. A default value will be assigned to new elements (if any).
- Parameters
node (
tlp.node
) – an existing nodesize (integer) – the new size of the list
- Throws
an exception if the node does not belong to the graph attached to the property
- resizeNodeValue(node, size, val)
Resizes the list attached to a particular node. The value given in parameter will be assigned to new elements (if any).
- Parameters
node (
tlp.node
) – an existing nodesize (integer) – the new size of the list
val (string) – the value to assign on new elements in the list
- Throws
an exception if the node does not belong to the graph attached to the property
- getEdgeEltValue(edge, index)¶
Returns the value in the list attached to a particular edge at the given index.
- Parameters
edge (
tlp.edge
) – an existing edgeindex (integer) – the index in the list
- Return type
string
- Throws
an exception if the edge does not belong to the graph attached to the property or if the list attached to the edge has a size smaller than the given index.
- setEdgeEltValue(edge, index, val)¶
Sets the value in the list attached to a particular edge at the given index.
- Parameters
edge (
tlp.edge
) – an existing edgeindex (integer) – the index in the list
val (string) – the value to set in the list
- Throws
an exception if the edge does not belong to the graph attached to the property or if the list attached to the edge has a size smaller than the given index.
- pushBackEdgeEltValue(edge, val)¶
Inserts a value at the end of the list attached to a particular edge. The size of the list is incremented by one.
- Parameters
edge (
tlp.edge
) – an existing edgeval (string) – the value to add in the list
- Throws
an exception if the edge does not belong to the graph attached to the property
- popBackEdgeEltValue(edge)¶
Removes the value at the end of the list (if not empty) attached to a particular edge. The size of the list is decremented by one.
- Parameters
edge (
tlp.edge
) – an existing edge- Throws
an exception if the edge does not belong to the graph attached to the property
- resizeEdgeValue(edge, size)¶
Resizes the list attached to a particular edge. A default value will be assigned to new elements (if any).
- Parameters
edge (
tlp.edge
) – an existing edgesize (integer) – the new size of the list
- Throws
an exception if the edge does not belong to the graph attached to the property
- resizeEdgeValue(edge, size, val)
Resizes the list attached to a particular edge. The value given in parameter will be assigned to new elements (if any).
- Parameters
edge (
tlp.edge
) – an existing edgesize (integer) – the new size of the list
val (string) – the value to assign on new elements in the list
- Throws
an exception if the node does not belong to the graph attached to the property
Tulip plugins classes¶
tlp.WithParameter¶
- class tlp.WithParameter¶
This class describes parameters for a plug-in. These parameters can be of multiple types, and are used to generate a GUI that will be shown when the plug-in in invoked by the user.
- addBooleanParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
Adds a boolean parameter to the plug-in.
- Parameters
name (string) – the name of the boolean parameter to add
help (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (“true” or “false”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addBooleanPropertyParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
Adds a
tlp.BooleanProperty
parameter to the plug-in.- Parameters
name (string) – the name of the
tlp.BooleanProperty
parameter to addhelp (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “<property_name>”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addBooleanVectorPropertyParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
New in version 4.2.
Adds a
tlp.BooleanVectorProperty
parameter to the plug-in.- Parameters
name (string) – the name of the
tlp.BooleanVectorProperty
parameter to addhelp (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “<property_name>”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addColorParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
Adds a
tlp.Color
parameter to the plug-in.- Parameters
name (string) – the name of the
tlp.Color
parameter to addhelp (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “(R, G, B, A)”, e.g. for red : “(255,0,0,255)”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addColorPropertyParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
Adds a
tlp.ColorProperty
parameter to the plug-in.- Parameters
name (string) – the name of the
tlp.ColorProperty
parameter to addhelp (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “<property_name>”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addColorScaleParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
Adds a
tlp.ColorScale
parameter to the plug-in.- Parameters
name (string) – the name of the
tlp.ColorScale
parameter to addhelp (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “((R, G, B, A), …, (R, G, B, A))”, e.g. gradient from black to white : “((0,0,0,255), (255,255,255,255))”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addColorVectorPropertyParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
New in version 4.2.
Adds a
tlp.ColorVectorProperty
parameter to the plug-in.- Parameters
name (string) – the name of the
tlp.ColorVectorProperty
parameter to addhelp (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “<property_name>”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addCoordVectorPropertyParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
New in version 4.2.
Adds a
tlp.CoorVectorProperty
parameter to the plug-in.- Parameters
name (string) – the name of the
tlp.LayoutProperty
parameter to addhelp (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “<property_name>”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addDirectoryParameter(name, help='', defaultValue='', isMandatory=True)¶
New in version 4.9.
Adds a directory parameter to the plug-in. A dialog will be created by the Tulip GUI in order to select an existing folder.
- Parameters
name (string) – the name of the directory parameter to add
help (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
- addDoublePropertyParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
Adds a
tlp.DoubleProperty
parameter to the plug-in.- Parameters
name (string) – the name of the
tlp.DoubleProperty
parameter to addhelp (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “<property_name>”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addDoubleVectorPropertyParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
New in version 4.2.
Adds a
tlp.DoubleVectorProperty
parameter to the plug-in.- Parameters
name (string) – the name of the
tlp.DoubleVectorProperty
parameter to addhelp (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “<property_name>”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addFileParameter(name, mustExist=True, help='', defaultValue='', isMandatory=True)¶
New in version 4.9.
Adds a file parameter to the plug-in. A dialog will be created by the Tulip GUI in order to select the file.
- Parameters
name (string) – the name of the file parameter to add
mustExist (boolean) – specify if the file must exist or not. This is used as a hint by the Tulip GUI to correctly configure the dialog that will be created for selecting the file.
help (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
- addFloatParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
Adds a floating point number parameter to the plug-in.
- Parameters
name (string) – the name of the floating point number parameter to add
help (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “[0-9]*[.][0-9]+”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addIntegerParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
Adds an integer parameter to the plug-in.
- Parameters
name (string) – the name of the integer parameter to add
help (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “[0-9]+”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addIntegerPropertyParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
Adds a
tlp.IntegerProperty
parameter to the plug-in.- Parameters
name (string) – the name of the
tlp.IntegerProperty
parameter to addhelp (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “<property_name>”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addIntegerVectorPropertyParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
New in version 4.2.
Adds a
tlp.IntegerVectorProperty
parameter to the plug-in.- Parameters
name (string) – the name of the
tlp.IntegerProperty
parameter to addhelp (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “<property_name>”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addLayoutPropertyParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
Adds a
tlp.LayoutProperty
parameter to the plug-in.- Parameters
name (string) – the name of the
tlp.LayoutProperty
parameter to addhelp (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “<property_name>”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addNumericPropertyParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
New in version 4.10.
Adds a
tlp.NumericProperty
parameter to the plug-in.- Parameters
name (string) – the name of the
tlp.NumericProperty
parameter to addhelp (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “<property_name>”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addPropertyParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
Adds a
tlp.PropertyInterface
parameter to the plug-in.- Parameters
name (string) – the name of the
tlp.PropertyInterface
parameter to addhelp (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “<property_name>”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addSizePropertyParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
Adds a
tlp.SizeProperty
parameter to the plug-in.- Parameters
name (string) – the name of the
tlp.SizeProperty
parameter to addhelp (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “<property_name>”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addSizeVectorPropertyParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
New in version 4.2.
Adds a
tlp.SizeVectorProperty
parameter to the plug-in.- Parameters
name (string) – the name of the
tlp.SizeVectorProperty
parameter to addhelp (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “<property_name>”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addStringCollectionParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
Adds a
tlp.StringCollection
parameter to the plug-in.- Parameters
name (string) – the name of the
tlp.StringCollection
parameter to addhelp (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “entry1;entry2;…;entryN”) gives the list of the possible values of the parameter to be defined; these values are separated by the character ‘;’ and the first value is the default one.
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addStringParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
Adds a string parameter to the plug-in.
- Parameters
name (string) – the name of the string parameter to add
help (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addStringPropertyParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
Adds a
tlp.StringProperty
parameter to the plug-in.- Parameters
name (string) – the name of the
tlp.StringProperty
parameter to addhelp (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “<property_name>”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addStringVectorPropertyParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
New in version 4.2.
Adds a
tlp.StringVectorProperty
parameter to the plug-in.- Parameters
name (string) – the name of the
tlp.StringVectorProperty
parameter to addhelp (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “<property_name>”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
- addUnsignedIntegerParameter(name, help='', defaultValue='', isMandatory=True, inParam=True, outParam=False, valuesDescription='')¶
New in version 5.0.
Adds an unsigned integer parameter to the plug-in.
- Parameters
name (string) – the name of the unsigned integer parameter to add
help (string) – a description of the parameter, that will be displayed to the user
defaultValue (string) – the default value (in the form “[0-9]+”) the parameter should take, to be the initial value in the GUI
isMandatory (boolean) – specify whether this parameter requires a value or not
inParam (boolean) – defines if the parameter is an input one (can be read by the plugin)
outParam (boolean) – defines if the parameter is an output one (can be written by the plugin and retrieved after its execution)
valuesDescription (string) – An optional description of the values the parameter can take.
tlp.Plugin¶
- class tlp.Plugin¶
Bases:
tlp.WithParameter
This is the base class for all Tulip plugins.
- author()¶
Returns the author of the plugin.
- Return type
string
- category()¶
Returns the category of the plugin.
- Return type
string
- date()¶
Returns the creation date of the plugin.
- Return type
string
- group()¶
Returns the group of the plugin.
- Return type
string
- icon()¶
New in version 5.0.
Returns the icon file path associated to the plugin.
- Return type
string
- id(self) int ¶
- info()¶
Returns some information about the plugin.
- Return type
string
- major(self) str ¶
- minor(self) str ¶
- name()¶
Returns the name of the plugin.
- Return type
string
- programmingLanguage(self) str ¶
- release()¶
Returns the release number of the plugin.
- Return type
string
- tulipMajor(self) str ¶
- tulipMinor(self) str ¶
- tulipRelease()¶
Returns the Tulip release number.
- Return type
string
tlp.Algorithm¶
- class tlp.Algorithm¶
Bases:
tlp.Plugin
This abstract class describes a general algorithm plugin. Basic functionality consists in checking the algorithm can run on the current Graph (e.g. is the graph simple ?) then running the algorithm. The algorithm can and should report progress and which task it is performing if it is decomposed in multiple phases (e.g. layouting the graph, coloring it, …).
class attributes
- dataSet¶
A dictionary containing input parameters for this algorithm, if any. It can also be used to write output parameters computed by the algorithm that will remain available after its execution.
- pluginProgress¶
A
tlp.PluginProgress
to give feedback to the user. It can beNone
, so use with caution.
class methods
- category(self) str ¶
- check()¶
This method is called before applying the algorithm on the input graph. You can perform some precondition checks here. Derived classes can reimplement it. Must return a tuple whose first member indicates if the algorithm can be applied and the second one can be used to provide an error message
- Return type
(Boolean, string)
- run()¶
This method is the entry point of the algorithm when it is called. Derived classes must implement it. It is a good practice to report progress through the PluginProgress. The PluginProgress should also be used to report errors, if any. A Boolean must also be returned to indicate if the algorithm was successful.
- Return type
Boolean
tlp.BooleanAlgorithm¶
- class tlp.BooleanAlgorithm¶
Bases:
tlp.Algorithm
This class is the base interface for selection plugins.
class attributes
- result¶
The result of the algorithm must be stored in this
tlp.BooleanProperty
.
- category(self) str ¶
tlp.ColorAlgorithm¶
- class tlp.ColorAlgorithm¶
Bases:
tlp.Algorithm
This class is the base interface for color plugins.
class attributes
- result¶
The result of the algorithm must be stored in this
tlp.ColorProperty
.
- category(self) str ¶
tlp.DoubleAlgorithm¶
- class tlp.DoubleAlgorithm¶
Bases:
tlp.Algorithm
This class is the base interface for metric plugins.
class attributes
- result¶
The result of the algorithm must be stored in this
tlp.DoubleProperty
.
- category(self) str ¶
tlp.IntegerAlgorithm¶
- class tlp.IntegerAlgorithm¶
Bases:
tlp.IntegerAlgorithm
This class is the base interface for integer plugins.
class attributes
- result¶
The result of the algorithm must be stored in this
tlp.IntegerProperty
.
- category(self) str ¶
tlp.LayoutAlgorithm¶
- class tlp.LayoutAlgorithm¶
Bases:
tlp.Algorithm
This class is the base interface for layout plugins.
class attributes
- result¶
The result of the algorithm must be stored in this
tlp.LayoutProperty
.
- category(self) str ¶
tlp.SizeAlgorithm¶
- class tlp.SizeAlgorithm¶
Bases:
tlp.Algorithm
This class is the base interface for size plugins.
class attributes
- result¶
The result of the algorithm must be stored in this
tlp.SizeProperty
.- category(self) str ¶
tlp.ImportModule¶
- class tlp.ImportModule¶
Bases:
tlp.Plugin
This abstract class describes an import plugin.
class attributes
- dataSet¶
A dictionary containing parameters for this import plugin, if any
- pluginProgress¶
A
tlp.PluginProgress
to give feedback to the user. It can beNone
, so use with caution
class methods
- category(self) str ¶
- fileExtensions()¶
New in version 5.0.
This method returns the extensions of file formats this plugin can import. Derived classes can implement it in order for the plugin to be automatically called by the
tlp.loadGraph()
function.- Return type
list of string
- importGraph()¶
This method is called to import a graph. Derived classes must implement it. A boolean must also be returned to indicate if the import was successful.
- Return type
boolean
tlp.ExportModule¶
- class tlp.ExportModule¶
Bases:
tlp.WithParameter
This abstract class describes an export plugin.
class attributes
- dataSet¶
A dictionary containing parameters for this export plugin, if any
- pluginProgress¶
A
tlp.PluginProgress
to give feedback to the user. It can beNone
, so use with caution
class methods
- category(self) str ¶
- exportGraph(os)¶
This method is called to export the graph to a file. Derived classes must implement it.
The os parameter is an output file stream (initialized by the Tulip GUI or by the
tlp.exportGraph()
function.). To write data to the file, you have to use the following syntax:# write the number of nodes and edges to the file os << self.graph.numberOfNodes() << "\n" os << self.graph.numberOfEdges() << "\n"
A Boolean must also be returned to indicate if the export was successful.
- Parameters
os (std.ostream) – an output file stream
- Return type
Boolean
- fileExtensions()¶
New in version 6.0.
This method returns a list of the extensions file format supported. The ones after the first are supposed to be gzip compressed. Derived class can implement it in order for the plugin to be automatically called by the
tlp.saveGraph()
function.- Return type
list of string
Graph test classes¶
tlp.SelfLoops¶
- class tlp.SelfLoops¶
The tlp.SelfLoops class represents a self loop that has been replaced by two nodes and three edges. The method
tlp.AcyclicTest.makeAcyclic()
returns a list of this type.It contains the following variables :
old (
tlp.edge
) : the self loop edge that has been replacedn1 (
tlp.node
) : the first node addedn2 (
tlp.node
) : the second node addede1 (
tlp.edge
) : the edge added between the node at the extremity of the loop and n1e2 (
tlp.edge
) : the edge added between n1 and n2e3 (
tlp.edge
) : the edge added between the node at the extremity of the loop and n2
tlp.AcyclicTest¶
- class tlp.AcyclicTest(a0: tlp.AcyclicTest)¶
- acyclicTest(graph)¶
Returns a tuple whose first member is a Boolean indicating if the graph is acyclic or not and second member is a list of edges that create cycle (when the graph is not acyclic).
- isAcyclic(graph)¶
Returns
True
if the graph is acyclic,False
if not. The result is cached (ie. the next call with the same graph is done in O(1) time)- Parameters
graph (
tlp.Graph
) – the graph on which to perform the acyclic test- Return type
Boolean
- makeAcyclic(graph)¶
Makes the graph acyclic, by reversing edge direction (feedback arc set problem). If there is self loops, a new node is added with two edges that points to it. Returns a tuple containing whose first member is a list of reversed edges and second member is a list of transformed self loops.
- Parameters
graph (
tlp.Graph
) – the graph to make acyclic- Return type
(list of
tlp.edge
, list oftlp.SelfLoops
)
tlp.BiconnectedTest¶
- class tlp.BiconnectedTest(a0: tlp.BiconnectedTest)¶
tlp.ConnectedTest¶
- class tlp.ConnectedTest(a0: tlp.ConnectedTest)¶
- computeConnectedComponents(graph)¶
Computes the sets of connected components. Returns a list of connected components.
- isConnected(graph)¶
Returns
True
if the graph is connected (ie. it exists an undirected path between each pair of nodes),False
otherwise.- Parameters
graph (
tlp.Graph
) – the graph on which to perform the connected test- Return type
Boolean
- makeConnected(graph)¶
If the graph is not connected, adds edges in order to make the graph connected. Returns a list of added edges.
tlp.OuterPlanarTest¶
- class tlp.OuterPlanarTest(a0: tlp.OuterPlanarTest)¶
- isOuterPlanar(graph)¶
Returns
True
if the graph is outerplanar (i.e. a graph with an embedding in the plane such that all vertices belong to the unbounded face of the embedding),False
otherwise.- Parameters
graph (
tlp.Graph
) – the graph on which to perform the outerplanarity test- Return type
boolean
tlp.PlanarityTest¶
- class tlp.PlanarityTest(a0: tlp.PlanarityTest)¶
- getObstructionsEdges(graph)¶
Returns a list of edges that prevents to make the graph planar (ie. part of the minor of K3,3 or K5).
- isPlanar(graph)¶
Returns
True
if the graph is planar (i.e. the graph can be drawn in such a way that no edges cross each other),False
otherwise.- Parameters
graph (
tlp.Graph
) – the graph on which to perform the planarity test- Return type
boolean
tlp.SimpleTest¶
- class tlp.SimpleTest(a0: tlp.SimpleTest)¶
- isSimple(graph, directed=False)¶
Returns
True
if the graph is simple (i.e. it contains no self loops or parallel edges),False
otherwise.- Parameters
graph (
tlp.Graph
) – the graph on which to perform the simple testdirected (boolean) – Indicates if the graph should be considered as directed or not
- Return type
boolean
- makeSimple(graph, directed=False)¶
Makes the graph simple by removing self loops and parallel edges if any. Returns a list of removed edges.
- simpleTest(graph, bool directed = False)¶
Performs a simple test and returns a tuple with 3 elements. The first element is a boolean indicating the result of the test. The second element is a list of found parallel edges. The third element is a list of found self loops.
tlp.TreeTest¶
- class tlp.TreeTest(a0: tlp.TreeTest)¶
- cleanComputedTree(graph, tree)¶
Cleans the graph from a tree previously computed with the
tlp.TreeTest.computeTree()
method.
- computeTree(graph)¶
Computes a rooted tree from the graph. The algorithm is the following :
if the graph is a rooted tree, returns the graph
if the graph is a free tree, returns a rooted clone subgraph
if the graph is connected, makes a clone subgraph and returns a rooted spanning tree of that clone
if the graph is not connected, makes a clone subgraph, computes a tree for each of its connected components, adds a simple source and returns the clone.
- isFreeTree(graph)¶
Returns
True
if the graph is a topological tree (i.e. if the graph was undirected, there would be no cycle),False
otherwise.- Parameters
graph (
tlp.Graph
) – the graph on which to perform the free tree test- Return type
boolean
tlp.TriconnectedTest¶
- class tlp.TriconnectedTest(a0: tlp.TriconnectedTest)¶
- isTriconnected(graph)¶
Returns
True
if the graph is triconnected (i.e. a connected graph such that deleting any two nodes (and incident edges) results in a graph that is still connected),False
otherwise.- Parameters
graph (
tlp.Graph
) – the graph on which to perform the triconnected test- Return type
boolean
Tulip Tools¶
Random number generation¶
There is no need to use Python API to generate random numbers. Use the Tulip dedicated functions to avoid any side effect with plugins using random numbers (e.g., Louvain, FM^3).
- tlp.initRandomSequence()¶
Deprecated since version 6.0.0.
- Initializes a random sequence with the seed previously set.
Use
tlp.setSeedOfRandomSequence()
with no argument instead.
- tlp.setSeedOfRandomSequence(seed)¶
Gives the value of the seed used for further generation of random numbers. Do not pass an argument if you prefer a random choice of the seed. Also initializes the random number generator with the new seed.
- Parameters
seed (integer) – the value of the seed
- tlp.getSeedOfRandomSequence()¶
Returns the value of the seed used to initialize the random number generator.
- Return type
integer
- tlp.randomDouble(max)¶
Returns a random double in the range [0, max]
- Parameters
max – the maximum number to generate
- Return type
double
- tlp.randomUnsignedInteger(max)¶
Returns a random unsigned integer in the range [0, max]
- Parameters
max – the maximum number to generate
- Return type
integer
- tlp.randomInteger(max)¶
Returns a random integer in the range [0, max] if max>0 else between [max, 0].
- Parameters
max – the maximum or minimum number to generate
- Return type
integer