A graph Interface.

exception core.graph.interface.graphconcept.GraphError[source]

Bases: exceptions.Exception

todo

exception core.graph.interface.graphconcept.InexistingVertex[source]

Bases: core.graph.interface.graphconcept.GraphError

todo

exception core.graph.interface.graphconcept.InvalidEdge[source]

Bases: core.graph.interface.graphconcept.GraphError, exceptions.KeyError

todo

exception core.graph.interface.graphconcept.InvalidGraph[source]

Bases: core.graph.interface.graphconcept.GraphError

todo

exception core.graph.interface.graphconcept.InvalidVertex[source]

Bases: core.graph.interface.graphconcept.GraphError, exceptions.KeyError

todo

class core.graph.interface.graphconcept.CopyConcept[source]

Copy Concept.

copy()[source]

Make a shallow copy

class core.graph.interface.graphconcept.EdgeListGraphConcept[source]

Bases: core.graph.interface.graphconcept.GraphConcept

Edge List Graph Concept

edges(vtx_id=None)[source]

Return an iterator of edge identifier. If vtx_id is specified, return input and output edges of vtx_id

Parameters:
  • vtx_id
Return:

iter of edge id

in_edges(vtx_id)[source]

Return input edges of vtx_id

Parameters:
  • vtx_id
Return:

iter of edges

nb_edges(vid=None)[source]
Return:int
nb_in_edges(vtx_id)[source]
Return:int
nb_out_edges(vtx_id)[source]
Return:int
out_edges(vtx_id)[source]

Return output edges of vtx_id

Parameters:
  • vtx_id
Return:

iter of edges

class core.graph.interface.graphconcept.ExtendConcept[source]

Extend the actul data structure with an other.

extend(graph)[source]

Extend the actual graph with graph PB: shift vertex id & edge id?

Parameters:
  • graph : a valid graph
class core.graph.interface.graphconcept.GraphConcept[source]

Bases: object

Graph concept or graph interface. To separate algo and data structures.

edge(source, target)[source]

Return the edge identifier or an iterator if the graph is a multiplegraph.

Parameters:
  • source: vtx_id
  • target: vtx_id
Return:

iter of edge_id

has_edge(edge_id)[source]

Test the existence of an edge in the graph.

Parameters:
  • edge_id: The edge identifier.
Return:

bool

has_vertex(vtx_id)[source]

Test the existence of a vertex in the graph.

Parameters:
  • vtx_id: The vertex identifier.
Return:

bool

is_valid()[source]

Is the graph valid?

Return:bool
source(edge_id)[source]

Return the source vertex of the edge.

Parameters:
  • edge_id: The edge identifier.
Types:
  • edge_id: id
Return:

vertex identifier

target(edge_id)[source]

Return the target vertex of the edge.

Parameters:
  • edge_id: The edge identifier.
Return:

vertex identifier

class core.graph.interface.graphconcept.MutableEdgeGraphConcept[source]

Bases: core.graph.interface.graphconcept.EdgeListGraphConcept

Mutable Edge Graph Concept.

add_edge(edge, edge_id=None, create_vertex=False)[source]

Add an edge to the graph.

Parameters:
  • edge: (vertex id, vertex id)
  • edge_id: optional edge identifier
  • create_vertex: optional flag for automatic vertices creation
clear_edges()[source]

Remove all edges.

edge_id()[source]

Return a free edge identifier

Return:edge_id
remove_edge(edge_id)[source]

Remove edge_id from the graph

Parameters:
  • edge_id : edge identifier
class core.graph.interface.graphconcept.MutableVertexGraphConcept[source]

Bases: core.graph.interface.graphconcept.VertexListGraphConcept

Mutable Vertex Graph Concept

add_vertex(vtx_id=None)[source]

Add a vertex to the graph.

Parameters:vtx_id -- optional vertex identifier
clear()[source]

Clear vertices and edges of the graph.

remove_vertex(vtx_id)[source]

Remove vertex from the graph

Parameters:vtx_id -- todo
vertex_id()[source]

Return a free vertex identifier

Returns:vtx_id
class core.graph.interface.graphconcept.VertexListGraphConcept[source]

Bases: core.graph.interface.graphconcept.GraphConcept

Vertex List Graph Concept.

in_neighbors(vtx_id)[source]
Return:iter of vertex_id
nb_in_neighbors(vtx_id)[source]
Return:int
nb_neighbors(vtx_id)[source]
Return:int
nb_out_neighbors(vtx_id)[source]
Return:int
nb_vertices()[source]

Return the number of vertices.

Return:int
neighbors(vtx_id)[source]
Return:iter of vertex_id
out_neighbors(vtx_id)[source]
Return:iter of vertex_id
vertices()[source]
Return:iter of vertex_id

Previous topic

<no title>

Next topic

<no title>

This Page