cellcomplex.graph.property_graph module¶
This module provide a set of concepts to add properties to graph elements
-
class
cellcomplex.graph.property_graph.PropertyGraph(graph=None, **kwds)[source]¶ Bases:
cellcomplex.graph.interface.property_graph.IPropertyGraph,cellcomplex.graph.graph.GraphSimple implementation of IPropertyGraph using dict as properties and two dictionaries to maintain these properties
-
add_edge_property(property_name, values=None)[source]¶ add a new map between eid and a data do not fill this property for any edge
-
add_region_from_func(func, region_name)[source]¶ Create a region region_name of vertices according to a function func.
- Parameters
func : the function to make the region (might return True or False)
region_name : the name of the region
-
add_regions_from_dict(dict_regions, region_names)[source]¶ If one already posses a dict indicating for a list of vertex which region they belong to, it can be given to the graph directly.
- Parameters
-
add_vertex_property(property_name, values=None)[source]¶ add a new map between vid and a data do not fill this property for any vertex
-
add_vertex_to_region(vids, region_name)[source]¶ Add a set of vertices vids to a region region_name. Save it in two places:
self.graph_property[region_name] will return the list of all vertices belonging to ‘region_name’;
self.vertex_property[“regions”][vid] will return the list of all regions vid belong to.
-
adjacency_matrix(edge_type=None, edge_dist=1, no_edge_val=0, oriented=True, reflexive=True, reflexive_value=0)[source]¶ Return the adjacency matrix of the graph. :Parameters: - edge_type : type of edges we want to consider - edge_dist : cost ot cost function to apply between two edges, default : 1 - no_edge_val : cost to put if there is no edge between two vertices, default : 0 - oriented : if True, the graph is considered oriented and we always add an edge j -> i if i -> j exists - reflexive : if True, the graph is considered reflexive and we will put the cost or the cost_function reflexive_value on the diagonal of the adjacency_matrix, default : 0
- Return
numpy.array : a NxN matrix
-
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
-
edges(vid=None, edge_type=None)[source]¶ - Return edges of the vertex vid
If vid=None, return all edges of the graph
- Parameters
vid : a vertex id
edges_type : type of edges we want to consider
:Returns
edge_list : the set of the edges of the vertex vid
-
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})
-
from_networkx(graph)[source]¶ Return a Graph from a NetworkX Directed graph. :Parameters:
graph : A NetworkX graph.
- Returns
-
get_property_value_type(propertyname, property_type=0)[source]¶ Return meta info on property value type.
-
graph_property(property_name)[source]¶ return a dict containing the graph properties/
- Return type
dict of
{property_name:data}
-
in_edges(vid, edge_type=None)[source]¶ Return in edges of the vertex vid
- Parameters
vid : a vertex id
edges_type : type of edges we want to consider (can be a set)
:Returns
edge_list : the set of the in edges of the vertex vid
-
in_neighbors(vid, edge_type=None)[source]¶ Return the in vertices of the vertex vid
- Parameters
vid : a vertex id
edges_type : type of edges we want to consider (can be a set)
:Returns
neighbors_list : the set of parent vertices of the vertex vid
-
iter_edges(vid, edge_type=None)[source]¶ - Return in edges of the vertex vid
If vid=None, return all edges of the graph
- Parameters
vid : a vertex id
edges_type : type of edges we want to consider
:Returns
iterator : an iterator on the set of the edges of the vertex vid
-
iter_in_edges(vid, edge_type=None)[source]¶ Return in edges of the vertex vid
- Parameters
vid : a vertex id
edges_type : type of edges we want to consider (can be a set)
:Returns
iterator : an iterator on the set of the in edges of the vertex vid
-
iter_in_neighbors(vid, edge_type=None)[source]¶ Return the in vertices of the vertex vid
- Parameters
vid : a vertex id
edges_type : type of edges we want to consider (can be a set)
:Returns
iterator : an iterator on the set of parent vertices of the vertex vid
-
iter_neighborhood(vid, n, edge_type=None)[source]¶ Return the neighborhood of the vertex vid at distance n (the disc, not the circle)
- Parameters
vids : a set of vertex id
:Returns
iterator : an iterator on the set of the vertices at distance n of the vertex vid
-
iter_neighbors(vid, edge_type=None)[source]¶ Return the neighbors vertices of the vertex vid
- Parameters
vid : a vertex id
edges_type : type of edges we want to consider (can be a set)
:Returns
iterartor : iterator on the set of neighobrs vertices of the vertex vid
-
iter_out_edges(vid, edge_type=None)[source]¶ Return in edges of the vertex vid
- Parameters
vid : a vertex id
edges_type : type of edges we want to consider
:Returns
iterator : an iterator on the set of the in edges of the vertex vid
-
iter_out_neighbors(vid, edge_type=None)[source]¶ Return the out vertices of the vertex vid
- Parameters
vid : a vertex id
edges_type : type of edges we want to consider (can be a set)
:Returns
iterator : an iterator on the set of child vertices of the vertex vid
-
metaeidtypepropertyname= 'valueproperty_as_eid'¶
-
metavidtypepropertyname= 'valueproperty_as_vid'¶
-
neighborhood(vid, max_distance=1, edge_type=None)[source]¶ Return the neighborhood of the vertex vid at distance max_distance (the disc, not the circle)
- Parameters
vid : vertex id
:Returns
neighbors_list : the set of the vertices at distance below max_distance of the vertex vid (including vid)
-
neighbors(vid, edge_type=None)[source]¶ Return the neighbors vertices of the vertex vid
- Parameters
vid : a vertex id
edges_type : type of edges we want to consider (can be a set)
:Returns
neighbors_list : the set of neighobrs vertices of the vertex vid
-
out_edges(vid, edge_type=None)[source]¶ Return out edges of the vertex vid
- Parameters
vid : a vertex id
edges_type : type of edges we want to consider (can be a set)
:Returns
edge_list : the set of the out edges of the vertex vid
-
out_neighbors(vid, edge_type=None)[source]¶ Return the out vertices of the vertex vid
- Parameters
vid : a vertex id
edges_type : type of edges we want to consider (can be a set)
:Returns
neighbors_list : the set of child vertices of the vertex 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
-
remove_vertex_from_region(vids, region_name)[source]¶ Remove a set of vertices vids from a region region_name.
-
set_graph_property_key_to_eid_type(propertyname)[source]¶ Give meta info on graph property key type. Associate it to Edge Id type
-
set_graph_property_key_to_vid_type(propertyname)[source]¶ Give meta info on graph property key type. Associate it to Vertex Id type
-
set_graph_property_value_to_eid_type(propertyname, property_type=1)[source]¶ Give meta info on property value type. Associate it to Edge Id type
-
set_graph_property_value_to_vid_type(propertyname, property_type=0)[source]¶ Give meta info on property value type. Associate it to Vertex Id type
-
topological_distance(vid, edge_type=None, edge_dist=<function PropertyGraph.<lambda>>, max_depth=inf, full_dict=True, return_inf=True)[source]¶ Return the distances of each vertices from the vertex vid according a cost function
- Parameters
vid (int) - a vertex id
edges_type (str) - type of edges we want to consider e.g. ‘s’ or ‘t’
edge_dist (function) - the cost function
max_depth (float) - the maximum depth that we want to reach
full_dict (bool) - if True this function will return the entire dictionary (with inf values)
return_inf (bool) - if True (default) return ‘inf’ values, else ‘nan’.
:Returns
dist_dict : a dictionary of the distances, key : vid, value : distance
-
translate_graph_property(prop_name, trans_vid, trans_eid)[source]¶ Translate a graph property according to meta info
-