openalea.core.graph package#

Subpackages#

Submodules#

openalea.core.graph.graph module#

This module provide a simple pure python implementation for a graph interface do not implement copy concept.

class openalea.core.graph.graph.Graph(graph=None)[source]#

Bases: IGraph, IVertexListGraph, IEdgeListGraph, IMutableVertexGraph, IMutableEdgeGraph, IExtendGraph

Directed graph with multiple links in this implementation: - vertices are tuple of edge_in, edge_out - edges are tuple of source,target

add_edge(edge=(None, None), eid=None)[source]#

add an edge to the graph, if eid is not provided create a new eid

Parameters:
  • edge : a tuple (vertex source,vertex target)

  • eid : the id of the created edge

Types:
  • edge : (vid,vid)

  • eid : eid

Returns:

the id of the newly created edge

Return type:

eid

add_vertex(vid=None)[source]#

add a vertex to the graph, if vid is not provided create a new vid

Parameters:

vid (vid) – the id of the vertex to add, default=None

Returns:

the id of the created vertex

Return type:

vid

clear()[source]#

remove all vertices and edges don’t change references to objects

clear_edges()[source]#

remove all the edges of the graph don’t change references to objects

edges(vid=None)[source]#

retrieve the edges linked to a specified vertex, all if vid is None

Parameters:

vid (vid) – id of the reference vertex, default=None

Return type:

iter of eid

extend(graph)[source]#

add the specified graph to self, create new vid and eid

Parameters:

graph (Graph) – the graph to add

Returns:

two dictionnary specifying correspondence between graph id and self id

Return type:

({vid:vid},{eid:eid})

has_edge(eid)[source]#

test wether an edge belong to the graph

Parameters:

eid (eid) – edge id to test

Return type:

bool

has_vertex(vid)[source]#

test wether a vertex belong to the graph

Parameters:

vid (vid) – vertex id to test

Return type:

bool

in_edges(vid)[source]#

retrieve the edges linked to a specified vertex, oriented inside the vertex

Parameters:

vid (vid) – id of the reference vertex, default=None

Return type:

iter of eid

in_neighbors(vid)[source]#

iterator on the neighbors of vid where edges are directed from neighbor to vid

Parameters:

vid (vid) – id of the reference vertex

Return type:

iter of vid

is_valid()[source]#

test the validity of the graph

Return type:

bool

nb_edges(vid=None)[source]#

number of edges linked to a specified vertex, total number if vid is None

Parameters:

vid (vid) – id of the reference vertex, default=None

Return type:

iter of eid

nb_in_edges(vid)[source]#

number of edges linked to a specified vertex, oriented inside vertex

Parameters:

vid (vid) – id of the reference vertex, default=None

Return type:

iter of eid

nb_in_neighbors(vid)[source]#

number of neighbors such as edges are directed from neighbor to vid

Parameters:

vid (vid) – id of the reference vertex

Return type:

int

nb_neighbors(vid)[source]#

number of neighbors regardless of the orientation of the edge

Parameters:

vid (vid) – id of the reference vertex

Return type:

int

nb_out_edges(vid)[source]#

number of edges linked to a specified vertex, oriented outside vertex

Parameters:

vid (vid) – id of the reference vertex, default=None

Return type:

iter of eid

nb_out_neighbors(vid)[source]#

number of neighbors such as edges are directed from vid to neighbor

Parameters:

vid (vid) – id of the reference vertex

Return type:

int

nb_vertices()[source]#

return the total number of vertices

Return type:

int

neighbors(vid)[source]#

iterator on the neighbors of vid regardless of the orientation of the edge

Parameters:

vid (vid) – id of the reference vertex

Return type:

iter of vid

out_edges(vid)[source]#

retrieve the edges linked to a specified vertex, oriented outside the vertex

Parameters:

vid (vid) – id of the reference vertex, default=None

Return type:

iter of eid

out_neighbors(vid)[source]#

iterator on the neighbors of vid where edges are directed from vid to neighbor

Parameters:

vid (vid) – id of the reference vertex

Return type:

iter of vid

remove_edge(eid)[source]#

remove a specified edge from the graph

Parameters:

eid (eid) – id of the edge to remove

remove_vertex(vid)[source]#

remove a specified vertex of the graph remove all the edges attached to it

Parameters:

vid (vid) – the id of the vertex to remove

source(eid)[source]#

retrieve the source of an edge

Parameters:

eid (eid) – id of the edge

Return type:

vid

target(eid)[source]#

retrieve the target of an edge

Parameters:

eid (eid) – id of the edge

Return type:

vid

vertices()[source]#

iterator on vertices

Return type:

iter of vid

openalea.core.graph.id_generator module#

This module provide a generator for id numbers

class openalea.core.graph.id_generator.IdGenerator[source]#

Bases: object

get_id(id=None)[source]#
release_id(id)[source]#

openalea.core.graph.property_graph module#

This module provide a set of concepts to add properties to graph elements

class openalea.core.graph.property_graph.PropertyGraph(graph=None)[source]#

Bases: IPropertyGraph, Graph

simple implementation of IPropertyGraph using dict as properties and two dictionaries to maintain these properties

add_edge_property(property_name)[source]#

add a new map between eid and a data do not fill this property for any edge

add_vertex_property(property_name)[source]#

add a new map between vid and a data do not fill this property for any vertex

clear()[source]#

remove all vertices and edges don’t change references to objects

clear_edges()[source]#

remove all the edges of the graph don’t change references to objects

edge_property(property_name)[source]#

return a map between eid and data for all edges where property_name is defined

Return type:

dict of {eid:data}

edge_property_names()[source]#

iter on names of all property maps defined on edge return iter of keys

extend(graph)[source]#

add the specified graph to self, create new vid and eid

Parameters:

graph (Graph) – the graph to add

Returns:

two dictionnary specifying correspondence between graph id and self id

Return type:

({vid:vid},{eid:eid})

remove_edge(eid)[source]#

remove a specified edge from the graph

Parameters:

eid (eid) – id of the edge to remove

remove_edge_property(property_name)[source]#

remove the map called property_name from the graph

remove_vertex(vid)[source]#

remove a specified vertex of the graph remove all the edges attached to it

Parameters:

vid (vid) – the id of the vertex to remove

remove_vertex_property(property_name)[source]#

remove the map called property_name from the graph

vertex_property(property_name)[source]#

return a map between vid and data for all vertices where property_name is defined

Return type:

dict of {vid:data}

vertex_property_names()[source]#

iter on names of all property maps defined on vertices return iter of keys

Module contents#