cdindex.cdindex module

cdindex.py: This script is an interface for the c extension _cdindex.

class cdindex.cdindex.Graph(vertices=[], edges=[])[source]

Create a graph.

This class defines a graph data structure on which to compute the cdindex and other functions that are made available through the module.

add_edge(source_name, target_name)[source]

Add a new edge to the graph.

This function adds a new edge to the graph, given a source name and target name.

Parameters:
  • source_name – The source vertex name.
  • target_name – The target vertex timestamp.
add_vertex(name, t)[source]

Add a new vertex to the graph.

This function adds a new vertex to the graph, given a name and timestamp.

Parameters:
  • name – The vertex name.
  • t (int) – The vertex timestamp.
cdindex(name, t_delta)[source]

Compute the CD index.

This function computes the CD index for a specified vertex at a given t_delta, where t_delta is an integer that gives the positive distance in time from the timestamp of the focal node when the index should be calculated.

Parameters:t_delta (int) – A time delta.
Returns:The CD index.
Return type:double
ecount()[source]

Return the number of edges in the graph.

This function returns the number of edges in the graph. Note that time is not taken into account. The total count of edges are returned regardless of when they appear in the graph.

Returns:The number of edges.
Return type:int
iindex(name, t_delta)[source]

Compute the I index.

This function computes the I index for a specified vertex at a given t_delta, where t_delta is an integer that gives the positive distance in time from the timestamp of the focal node when the index should be calculated. The I index is the in degree of the focal node at time t.

Parameters:t_delta (int) – A time delta.
Returns:The I index.
Return type:double
in_degree(name)[source]

Return the in degree of the focal vertex.

Given a vertex, this function returns its in degree centrality, i.e., the number of other vertices in the graph that cite the focal vertex. Note that time is not taken into account. The function counts edges regardless of when they appear in the graph.

Parameters:name – The vertex name.
Returns:The in degree centrality.
Return type:int
in_edges(name)[source]

Return the in edges of the focal vertex.

Given a vertex, this function returns its in edges, i.e., the other vertices in the graph cited by the focal vertex. Note that time is not taken into account. The function returns edges regardless of when they appear in the graph.

Parameters:name – The vertex name.
Returns:The in edges.
Return type:list
mcdindex(name, t_delta)[source]

Compute the mCD index.

This function computes the mCD index for a specified vertex at a given t_delta, where t_delta is an integer that gives the positive distance in time from the timestamp of the focal node when the index should be calculated.

Parameters:t_delta (int) – A time delta.
Returns:The mCD index.
Return type:double
out_degree(name)[source]

Return the out degree of the focal vertex.

Given a vertex, this function returns its out degree centrality, i.e., the number of other vertices in the graph cited by the focal vertex. Note that time is not taken into account. The function counts edges regardless of when they appear in the graph.

Parameters:name – The vertex name.
Returns:The out degree centrality.
Return type:int
out_edges(name)[source]

Return the out edges of the focal vertex.

Given a vertex, this function returns its out edges, i.e., the other vertices in the graph cited by the focal vertex. Note that time is not taken into account. The function returns edges regardless of when they appear in the graph.

Parameters:name – The vertex name.
Returns:The out edges.
Return type:list
timestamp(name)[source]

Return the timestamp of the focal vertex.

Given a vertex, this function returns its timestamp.

Parameters:name – The vertex name.
Returns:The timestamp.
Return type:int
vcount()[source]

Return the number of vertices in the graph.

This function returns the number of vertices in the graph. Note that time is not taken into account. The total count of vertices are returned regardless of when they appear in the graph.

Returns:The number of vertices.
Return type:int
vertices()[source]

Return the vertices in the graph.

This function returns a list of vertices in the graph. Note that time is not taken into account. Vertices are returned regardless of when they appear in the graph.

Returns:The vertices.
Return type:list
class cdindex.cdindex.RandomGraph(generations=[], edge_fraction=[])[source]

Bases: cdindex.cdindex.Graph

Create a random graph.

This class generates a random graph that can be used for testing the cdindex and other functions that are made available through the module.

cdindex.cdindex.main()[source]