Overview

DyNetworkX is a Python package for the study of dynamic network analysis (DNA). It is a fork of NetworkX package. Thus, implementation, documentation and the development of DyNetworkX is heavily influenced by NetworkX.

DyNetworkX provides

  • tools for the study of the structure of dynamic networks.
  • all dynamic graph types can be converted to one or more of NetworkX graph types, allowing access to a verity of network algorithms.

Audience

The audience for DyNetworkX includes mathematicians, physicists, biologists, computer scientists, and social scientists. Overall, everyone interested in analyzing dynamic networks.

Python

Python is a powerful programming language that allows simple and flexible representations of networks as well as clear and concise expressions of network algorithms. Python has a vibrant and growing ecosystem of packages that NetworkX uses to provide more features such as numerical linear algebra and drawing. In order to make the most out of NetworkX you will want to know how to write basic programs in Python. Among the many guides to Python, we recommend the Python documentation.

Free software

Released under the 3-Clause BSD license. More information can be found under Licence.

History

DyNetworkX is developed by IDEAS Lab @ The University of Toledo.

Documentation

Date:Mar 13, 2020

Install

Just like NetworkX, DyNetworkX requires Python 3.4, 3.5, or 3.6.

Below we assume you have the default Python environment already configured on your computer and you intend to install networkx inside of it. If you want to create and work with Python virtual environments, please follow instructions on venv and virtual environments.

First, make sure you have the latest version of pip (the Python package manager) installed. If you do not, refer to the Pip documentation and install pip first.

Note

DyNetworkX is not yet available for pip install. If you are interested in this DyNetworkX, contact us from Need Help? and we will keep you updated.

Tutorial

This guide can help you start working with IntervalGraph module of DyNetworkX.

Disclaimer: this tutorial, similar to DyNetworkX itself, is heavily influenced by NetworkX’s tutorial. This is done on purpose, in order to point out the similarities between the two packages.

Creating an interval graph

Create an empty interval graph with no nodes and no edges.

>>> import dynetworkx as dnx
>>> IG = dnx.IntervalGraph()

By definition, an IntervalGraph is a collection of nodes (vertices) along with identified pairs of nodes (called interval edges, edges, links, etc) each of which is coupled with a given interval. In DyNetworkX, just like NetworkX, nodes can be any hashable object e.g., a text string, an image, an XML object, another Graph, a customized node object, etc.

Note

Python’s None object should not be used as a node as it determines whether optional function arguments have been assigned in many functions.

Nodes

Using DyNetworkX’s IntervalGraph.load_from_txt() method, the graph IG can be grown by importing an existing network. However, we first look at simple ways to manipulate an interval graph. The simplest form is adding a single node,

>>> IG.add_node(1)

add a list of nodes,

>>> IG.add_nodes_from([2, 3])

or add any iterable container of nodes. You can also add nodes along with node attributes if your container yields 2-tuples (node, node_attribute_dict). Node attributes are discussed further below.

>>> H = dnx.IntervalGraph()
>>> IG.add_node(H)

Note that interval graph IG now contains interval graph H as a node. This flexibility is very powerful as it allows graphs of graphs, graphs of files, graphs of functions and much more. It is worth thinking about how to structure your application so that the nodes are useful entities. Of course you can always use a unique identifier in IG and have a separate dictionary keyed by identifier to the node information if you prefer.

Note

You should not change the node object if the hash depends on its contents.

Edges

Edges are what make an interval graph possible. Every edge is defined by 2 nodes, the inclusive beginning of the interval when the edge first appears and its non-inclusive end. Beginning of an interval must be strictly smaller than its end and both can be of any orderable types.

Note

In this tutotial as well as IntervalGraph documentation, the two terms edge and interval edge are used interchangeably.

IG can also be grown by adding one edge at a time,

>>> IG.add_edge(1, 2, 1, 4) # n1, n2, beginning, end of the edge interval
>>> ie = (2, 3, 2, 5)
>>> IG.add_edge(*ie) # unpack interval edge tuple*

by adding a list of edges,

>>> IG.add_edges_from([(1, 2, 2, 6), (1, 3, 6, 9)])

or by adding any ebunch of edges. An ebunch is any iterable container of interval edge-tuples. An interval edge-tuple is a 4-tuple of nodes and intervals.

Note

In above example it is worth noting that the two added interval edges, (1, 2, 1, 4) and (1, 2, 2, 6) are two different interval edges, since they exists on different intervals.

If a new interval edge is to be added with nodes that are not currently in the interval graph, nodes will be added automatically.

There are no complaints when adding existing nodes or edges. As we add new nodes/edges, DyNetworkX quietly ignores any that are already present.

>>> IG.add_edge(1, 2, 1, 4)
>>> IG.add_node(1)

At this stage the interval graph IG consist of 4 nodes and 4 edges,

>>> IG.number_of_nodes()
4
>>> len(IG.edges())
4

We can examine nodes and edges with two interval graph methods which facilitate reporting: IntervalGraph.nodes() and IntervalGraph.edges(). These are lists of the nodes and interval edges. They offer a continually updated read-only view into the graph structure.

>>> IG.nodes()
[1, 2, 3, <dynetworkx.classes.intervalgraph.IntervalGraph object at 0x100000000>]

IG.edges() is an extremely flexible and useful method to query the interval graph for various interval edges. It returns a list of Interval objects which are in the form Interval(begin, end, (node_1, node_2).

Using this method you have access to 4 constraints in order to restrict your query. u, v, begin and end. Defining any of them narrows down your query.

>>> IG.edges() # returns a list of all edges
[Interval(6, 9, (1, 3)), Interval(2, 5, (2, 3)), Interval(2, 6, (1, 2)), Interval(1, 4, (1, 2))]
>>> IG.edges(begin=5) # all edges which have an overlapping interval with interval [5, end of the interval graph]
[Interval(6, 9, (1, 3)), Interval(2, 6, (1, 2))]
>>> IG.edges(end=3) # all edges which have an overlapping interval with interval [beginning of the interval graph, 3)
[Interval(2, 5, (2, 3)), Interval(2, 6, (1, 2)), Interval(1, 4, (1, 2))]
>>> IG.edges(u=1, v=2) # all edge between nodes 1 and 2
[Interval(2, 6, (1, 2)), Interval(1, 4, (1, 2))]
>>> IG.edges(1, 2, 5, 6) # all edges between nodes 1 and 2 which have an overlapping interval with [5, 6)
[Interval(2, 6, (1, 2))]

One can also take advantage of this method to obtain more information such as degree. Since in an interval graph these parameters change depending on the interval in question, you need to adjust your query.

Accessing degree of a node:

>>> len(IG.edges(u=1)) # total number of edges associated with node 1 over the entire interval
3
>>> len(IG.edges(u=1, begin=2, end=4)) # Adding interval restriction
2

Keep in mind that end is non-inclusive. Thus, depening on what time increment you use to define your interval, if you set end = begin + smallest_increment it will return all the edges which are present at time begin.

>>> len(IG.edges(u=1, begin=5, end=6))
1

If you are using a truly continuous time interval, you can add your machine epsilon to begin to achieve the same result. As an example:

>>> import numpy as np
>>> eps = np.finfo(np.float64).eps
>>> begin = 5
>>> IG.edges(u=1, begin=begin, end=begin + eps)
[Interval(2, 6, (1, 2))]

As it is shown, IG.edges() is a powerful method to query the network for edges. You can also take advantage of IntervalGraph.has_node() and IntervalGraph.has_edge() as it is shown below,

>>> IG.has_node(3)
True
>>> 1 in IG # this is equivalent to IG.has_node(1)
True
>>> IG.has_node(5)
False
>>> IG.has_edge(2, 3)
True
>>> IG.has_edge(1, H)
False

Or constraint the begin and/or end of your search:

>>> IG.has_node(3, end=2) # end is non-inclusive
False
>>> IG.has_edge(2, 3, 3, 7) # matching an interval edge with nodes 2 and 3, and overlapping interval [3, 7)
True
>>> IG.has_edge(2, 3, 3, 7, overlapping=False) # setting overlapping=False, searches for an exact interval match
False

One can remove nodes and edges from the graph in a similar fashion to adding. by using IntervalGraph.remove_node() and IntervalGraph.remove_edge(), e.g.

>>> IG.remove_node(H)
[1, 2, 3]
>>> IG.remove_edge(1, 3, 6, 9, overlapping=False)
>>> IG.edges()
[Interval(2, 5, (2, 3)), Interval(2, 6, (1, 2)), Interval(1, 4, (1, 2))]

What to use as nodes and edges

Just like NetworkX, DyNetworkX does not have a specific type for nodes an edges. This allows you to represent nodes and edges with any hashable object to add more depth and meanning to your interval graph. The most common choices are numbers or strings, but a node can be any hashable object (except None), and an edge can be associated with any object x using IG.add_edge(n1, n2, begin, end, object=x).

As an example, n1 and n2 could be real people’s profile url or a custom python object and x can be another python object which describes the detail of their contact. This way, you are not bound to only associating weights with the edges.

Based on the NetworkX’s experience, this is quite useful, but its abuse can lead to unexpected surprises unless one is familiar with Python.

Adding attributes to graphs, nodes, and edges

Attributes such as weights, labels, colors, or whatever Python object you like, can be attached to graphs, nodes, or edges.

Each graph, node, and edge can hold key/value attribute pairs in an associated attribute dictionary (the keys must be hashable). By default these are empty, but attributes can be added or changed using add_edge, add_node.

Graph attributes

Assign graph attributes when creating a new graph,

>>> IG = dnx.IntervalGraph(state='Ohio')
>>> IG.graph
{'state': 'Ohio'}

Or you can modify attributes later,

>>> IG.graph['state'] = 'Michigan'
>>> IG.graph
{'state': 'Michigan'}

There is also an spacial attribute for interval graphs called name. You can either set it just like any other attribute or you can take advantage of the IG.name property:

>>> IG.name = "USA"
>>> IG.name
USA
Node attributes

Add node attributes using add_node() or add_nodes_from(),

>>> IG.add_node(1, time='5pm', day="Friday") # Adds node 1 and sets its two attributes
>>> IG.add_nodes_from([2, 3], time='2pm') # Adds nodes 2 and 3 and sets both of their 'time' attributes to '2pm'
>>> IG.add_node(1, time='10pm') # Updates node 1's 'time' attribute to '10pm'

Note that you can update a node’s attribute by adding the node and setting a new value for its attribute.

Edge attributes

Similarly, add/change edge attributes using add_edge() or add_edges_from(),

>>> G.add_edge(1, 2, 4, 6, contact_type='call') # Adds the edge and sets its 'contact_type' attribute.
>>> G.add_edges_from([(3, 4, 1, 5), (1, 2, 4, 6)], weight=5.8)
>>> G.add_edge(1, 2, 4, 6, weight=6.6) # Updates the weight attribute of the edge.

Note that updating an edge’s attribute is similar to updating nodes’ attributes.

Subgraphs and snapshots

You can create one, or a series of snapshots of, NetworkX Graph or MultiGraph from an interval graph if you wish to analyze a portion, or your entire interval graph, using well-known static network algorithms that are available in NetworkX.

Subgraphs

To extract a portion of an interval graph, given an interval, you can utilize IntervalGraph.to_subgraph(),

>>> IG = dnx.IntervalGraph()
>>> IG.add_edges_from([(1, 2, 3, 10), (2, 4, 1, 11), (6, 4, 12, 19), (2, 4, 8, 15)])
>>> H = IG.to_subgraph(4, 12)
>>> type(H)
<class 'networkx.classes.graph.Graph'>
>>> list(H.edges(data=True))
[(1, 2, {}), (2, 4, {})]

Note that you can also use IntervalGraph.interval() to get the interval for the entire interval graph, and use that to convert an interval graph to a NetworkX Graph.

You can also keep the information about each edge’s interval as attributes on the NetworkX’s Graph:

>>> H = G.to_subgraph(4, 12, edge_interval_data=True)
>>> type(H)
<class 'networkx.classes.graph.Graph'>
>>> list(H.edges(data=True))
[(1, 2, {'end': 10, 'begin': 3}), (2, 4, {'end': 15, 'begin': 8})]

Notice that if there are multiple edges available between two nodes, the interval information is going to reflect only one of the edges. Another option is to retrieve a MultiGraph to lose less information in the conversion process:

>>> M = G.to_subgraph(4, 12, multigraph=True, edge_interval_data=True)
>>> type(M)
<class 'networkx.classes.multigraph.MultiGraph'>
>>> list(M.edges(data=True))
[(1, 2, {'end': 10, 'begin': 3}), (2, 4, {'end': 11, 'begin': 1}), (2, 4, {'end': 15, 'begin': 8})]
Snapshots

A more traditional method of analyzing continuous dynamic networks has been dividing the network into a series of fixed-interval snapshots. Although some information will be lost in the conversion due to the classic limitations of representing a continuous network in a discrete format, you will gain access to numerous well-defined algorithms which do not exist for continuous networks.

To do so, you can simply use IntervalGraph.to_snapshots() and set the number of snapshots you wish to divided the network into:

>>> S, l = G.to_snapshots(2, edge_interval_data=True, return_length=True)
>>> S # a list of NetworkX Graphs
[<networkx.classes.graph.Graph object at 0x100000>, <networkx.classes.graph.Graph object at 0x150d00>]
>>> l # length of the interval of a single snapshot
9.0
>>> for g in S:
>>> ... g.edges(data=True))
[(1, 2, {'begin': 3, 'end': 10}), (2, 4, {'begin': 8, 'end': 15})]
[(2, 4, {'begin': 8, 'end': 15}), (4, 6, {'begin': 12, 'end': 19})]

Combining this method with SnapshotGraph can be a powerful tool to gain access to all the methods available through DyNetworkX’s SnapshotGraph.

Similar to to_subgraph method, you can also divide the interval graph into a series of NetworkX’s MultiGraph, if that is what you need.

Importing from text file

Using load_from_txt you can also read in an IntervalGraph or ImpulseGraph from a text file in a specific edge-list format. For more detail checkout the documentation on IntervalGraph.load_from_txt().

Saving to text file

Using save_to_txt you can also write an IntervalGraph or ImpulseGraph to a text file in a specific edge-list format. For more detail checkout the documentation on IntervalGraph.save_to_txt().

Download

Software

DyNetworkX package is still under development as of now, and there is no stable version available through PyPI. However, if you wish to try the dev version for yourself, you can fork the github repository .

Reference

Date:Mar 13, 2020

Introduction

The structure of DyNetworkX closely (and intentionally) resembles the structure of NetworkX, since it is a fork of NetworkX.

DyNetworkX Basics

After starting Python, import the dynetworkx module with (the recommended way)

>>> import dynetworkx as dnx

To save repetition, in the documentation we assume that DyNetworkX has been imported this way.

If importing networkx fails, it means that Python cannot find the installed module. Check your installation and your PYTHONPATH.

The following basic graph types are provided as Python classes:

IntervalGraph
This class implements an undirected interval graph. Each edge must have a beginning and ending as an interval. It ignores multiple edges (edges with the same nodes and interval) between two nodes. It does allow self-loop edges between a node and itself.
SnapshotGraph
This class implements an easy way to gain access to a list of NetworkX networks and provides various methods to interact, manipulate and analyze the networks.

Graph Types

Interval Graph
Overview
class dynetworkx.IntervalGraph(**attr)

Base class for undirected interval graphs.

The IntervalGraph class allows any hashable object as a node and can associate key/value attribute pairs with each undirected edge.

Each edge must have two integers, begin and end for its interval.

Self-loops are allowed but multiple edges (two or more edges with the same nodes, begin and end interval) are not.

Two nodes can have more than one edge with different overlapping or non-overlapping intervals.

Parameters:attr (keyword arguments, optional (default= no attributes)) – Attributes to add to graph as key=value pairs.

Examples

Create an empty graph structure (a “null interval graph”) with no nodes and no edges.

>>> G = dnx.IntervalGraph()

G can be grown in several ways.

Nodes:

Add one node at a time:

>>> G.add_node(1)

Add the nodes from any container (a list, dict, set or even the lines from a file or the nodes from another graph).

Add the nodes from any container (a list, dict, set)

>>> G.add_nodes_from([2, 3])
>>> G.add_nodes_from(range(100, 110))

Edges:

G can also be grown by adding edges. This can be considered the primary way to grow G, since nodes with no edge will not appear in G in most cases. See G.to_snapshot().

Add one edge, which starts at 0 and ends at 10. Keep in mind that the interval is [0, 10). Thus, it does not include the end.

>>> G.add_edge(1, 2, 0, 10)

a list of edges,

>>> G.add_edges_from([(1, 2, 0, 10), (1, 3, 3, 11)])

If some edges connect nodes not yet in the graph, the nodes are added automatically. There are no errors when adding nodes or edges that already exist.

Attributes:

Each interval graph, node, and edge can hold key/value attribute pairs in an associated attribute dictionary (the keys must be hashable). By default these are empty, but can be added or changed using add_edge, add_node.

Keep in mind that the edge interval is not an attribute of the edge.

>>> G = dnx.IntervalGraph(day="Friday")
>>> G.graph
{'day': 'Friday'}

Add node attributes using add_node(), add_nodes_from()

>>> G.add_node(1, time='5pm')
>>> G.add_nodes_from([3], time='2pm')

Add edge attributes using add_edge(), add_edges_from().

>>> G.add_edge(1, 2, 0, 10, weight=4.7 )
>>> G.add_edges_from([(3, 4, 3, 11), (4, 5, 0, 33)], color='red')

Shortcuts:

Here are a couple examples of available shortcuts:

>>> 1 in G  # check if node in interval graph during any interval
True
>>> len(G)  # number of nodes in the entire interval graph
5

Subclasses (Advanced): Edges in interval graphs are represented by Interval Objects and are kept in an IntervalTree. Both are based on intervaltree available in pypi (https://pypi.org/project/intervaltree). IntervalTree allows for fast interval based search through edges, which makes interval graph analysis possible.

The Graph class uses a dict-of-dict-of-dict data structure. The outer dict (node_dict) holds adjacency information keyed by nodes. The next dict (adjlist_dict) represents the adjacency information and holds edge data keyed by interval objects. The inner dict (edge_attr_dict) represents the edge data and holds edge attribute values keyed by attribute names.

Methods
Adding and removing nodes and edges
IntervalGraph.__init__(**attr) Initialize an interval graph with edges, name, or graph attributes.
IntervalGraph.add_node(node_for_adding, **attr) Add a single node node_for_adding and update node attributes.
IntervalGraph.add_nodes_from(…) Add multiple nodes.
IntervalGraph.remove_node(n[, begin, end]) Remove the presence of a node n within the given interval.
IntervalGraph.add_edge(u, v, begin, end, **attr) Add an edge between u and v, during interval [begin, end).
IntervalGraph.add_edges_from(ebunch_to_add, …) Add all the edges in ebunch_to_add.
IntervalGraph.remove_edge(u, v[, begin, …]) Remove the edge between u and v in the interval graph, during the given interval.
Reporting interval graph, nodes and edges
IntervalGraph.nodes([begin, end, data, default]) A NodeDataView of the IntervalGraph nodes.
IntervalGraph.has_node(n[, begin, end]) Return True if the interval graph contains the node n, during the given interval.
IntervalGraph.edges([u, v, begin, end, …]) Returns a list of Interval objects of the IntervalGraph edges.
IntervalGraph.has_edge(u, v[, begin, end, …]) Return True if there exists an edge between u and v in the interval graph, during the given interval.
IntervalGraph.__contains__(n) Return True if n is a node, False otherwise.
IntervalGraph.__str__() Return the interval graph name.
IntervalGraph.interval() Return a 2-tuple as (begin, end) interval of the entire
Counting nodes and edges
IntervalGraph.number_of_nodes([begin, end]) Return the number of nodes in the interval graph between the given interval.
IntervalGraph.__len__() Return the number of nodes.
Making copies and subgraphs
IntervalGraph.to_subgraph(begin, end[, …]) Return a networkx Graph or MultiGraph which includes all the nodes and edges which have overlapping intervals with the given interval.
IntervalGraph.to_snapshots(number_of_snapshots) Return a list of networkx Graph or MultiGraph objects as snapshots of the interval graph in consecutive order.
Loading an interval graph
IntervalGraph.load_from_txt(path[, …]) Read interval graph in from path.
IntervalGraph.save_to_txt(path[, delimiter]) Write interval graph to path.
Analyzing interval graphs
IntervalGraph.degree([node, begin, end, delta]) Return the degree of a specified node between time begin and end.
Impulse Graph
Overview
class dynetworkx.ImpulseGraph(name='', **attr)

Base class for undirected interval graphs.

The ImpulseGraph class allows any hashable object as a node and can associate key/value attribute pairs with each undirected edge.

Each edge must have one integer, timestamp.

Self-loops are allowed. Multiple edges between two nodes are allowed.

Parameters:attr (keyword arguments, optional (default= no attributes)) – Attributes to add to graph as key=value pairs.

Examples

Create an empty graph structure (a “null interval graph”) with no nodes and no edges.

>>> G = dnx.ImpulseGraph()

G can be grown in several ways.

Nodes:

Add one node at a time:

>>> G.add_node(1)

Add the nodes from any container (a list, dict, set or even the lines from a file or the nodes from another graph).

Add the nodes from any container (a list, dict, set)

>>> G.add_nodes_from([2, 3])
>>> G.add_nodes_from(range(100, 110))

Edges:

G can also be grown by adding edges. This can be considered the primary way to grow G, since nodes with no edge will not appear in G in most cases. See G.to_snapshot().

Add one edge, with timestamp of 10.

>>> G.add_edge(1, 2, 10)

a list of edges,

>>> G.add_edges_from([(1, 2, 10), (1, 3, 11)])

If some edges connect nodes not yet in the graph, the nodes are added automatically. There are no errors when adding nodes or edges that already exist.

Attributes:

Each impulse graph, node, and edge can hold key/value attribute pairs in an associated attribute dictionary (the keys must be hashable). By default these are empty, but can be added or changed using add_edge, add_node.

Keep in mind that the edge timestamp is not an attribute of the edge.

>>> G = dnx.IntervalGraph(day="Friday")
>>> G.graph
{'day': 'Friday'}

Add node attributes using add_node(), add_nodes_from()

>>> G.add_node(1, time='5pm')
>>> G.add_nodes_from([3], time='2pm')

Add edge attributes using add_edge(), add_edges_from().

>>> G.add_edge(1, 2, 10, weight=4.7 )
>>> G.add_edges_from([(3, 4, 11), (4, 5, 33)], color='red')

Shortcuts:

Here are a couple examples of available shortcuts:

>>> 1 in G  # check if node in impulse graph during any timestamp
True
>>> len(G)  # number of nodes in the entire impulse graph
5

Subclasses (Advanced): Edges in impulse graphs are represented by tuples kept in a SortedDict (http://www.grantjenks.com/docs/sortedcontainers/) keyed by timestamp.

The Graph class uses a dict-of-dict-of-dict data structure. The outer dict (node_dict) holds adjacency information keyed by nodes. The next dict (adjlist_dict) represents the adjacency information and holds edge data keyed by interval objects. The inner dict (edge_attr_dict) represents the edge data and holds edge attribute values keyed by attribute names.

Methods
Adding and removing nodes and edges
ImpulseGraph.__init__([name]) Initialize an interval graph with edges, name, or graph attributes.
ImpulseGraph.add_node(node_for_adding, **attr) Add a single node node_for_adding and update node attributes.
ImpulseGraph.add_nodes_from(…) Add multiple nodes.
ImpulseGraph.remove_node(n[, begin, end, …]) Remove the presence of a node n within the given interval.
ImpulseGraph.add_edge(u, v, t, **attr) Add an edge between u and v, at t.
ImpulseGraph.add_edges_from(ebunch_to_add, …) Add all the edges in ebunch_to_add.
ImpulseGraph.remove_edge(u, v[, begin, end, …]) Remove the edge between u and v in the impulse graph, during the given interval.
Reporting impulse graph, nodes and edges
ImpulseGraph.nodes([begin, end, inclusive, …]) A NodeDataView of the ImpulseGraph nodes.
ImpulseGraph.has_node(n[, begin, end, inclusive]) Return True if the impulse graph contains the node n, during the given interval.
ImpulseGraph.edges([u, v, begin, end, …]) Returns a list of Interval objects of the IntervalGraph edges.
ImpulseGraph.has_edge(u, v[, begin, end, …]) Return True if there exists an edge between u and v in the impulse graph, during the given interval.
ImpulseGraph.__contains__(n) Return True if n is a node, False otherwise.
ImpulseGraph.__str__() Return the interval graph name.
ImpulseGraph.interval() Return a 2-tuple as (begin, end) interval of the entire
Counting nodes and edges
ImpulseGraph.number_of_nodes([begin, end, …]) Return the number of nodes in the impulse graph between the given interval.
ImpulseGraph.__len__() Return the number of nodes.
Making copies and subgraphs
ImpulseGraph.to_subgraph(begin, end[, …]) Return a networkx Graph or MultiGraph which includes all the nodes and edges which have timestamps within the given interval.
ImpulseGraph.to_snapshots(number_of_snapshots) Return a list of networkx Graph or MultiGraph objects as snapshots of the impulse graph in consecutive order.
Loading an impulse graph
ImpulseGraph.load_from_txt(path[, …]) Read impulse graph in from path.
ImpulseGraph.save_to_txt(path[, delimiter]) Write impulse graph to path.
Analyzing impulse graphs
ImpulseGraph.degree([node, begin, end, delta]) Return the degree of a specified node between time begin and end.
Snapshot Graph
Overview
class dynetworkx.SnapshotGraph(**attr)
Methods
Adding and removing nodes and edges
SnapshotGraph.__init__(**attr) Initialize self.
SnapshotGraph.add_nodes_from(nbunch[, sbunch]) Adds nodes to snapshots in sbunch.
SnapshotGraph.add_edges_from(ebunch[, sbunch]) Adds edges to snapshots in sbunch.
Manipulating Snapshots
SnapshotGraph.insert(graph[, snap_len, …]) Insert a graph into the snapshot graph, with options for inserting at a given index, with some snapshot length.
SnapshotGraph.add_snapshot([ebunch, graph, …]) Add a snapshot with a bunch of edge values.
Reporting Snapshots
SnapshotGraph.__len__() Return the number of snapshots.
SnapshotGraph.order([sbunch]) Returns order of each graph requested in ‘sbunch’.
SnapshotGraph.has_node(n[, sbunch]) Gets boolean list of if a snapshot in ‘sbunch’ contains node ‘n’.
SnapshotGraph.size([sbunch, weight]) Returns the size of each graph index as specified in sbunch as a list.
SnapshotGraph.is_directed([sbunch]) Returns a list of boolean values for if the graph at the index is a directed graph.
SnapshotGraph.is_multigraph([sbunch]) Returns a list of boolean values for if the graph at the index is a multigraph.
SnapshotGraph.number_of_nodes([sbunch]) Gets number of nodes in each snapshot requested in ‘sbunch’.
SnapshotGraph.degree([sbunch, nbunch, weight]) Return a list of tuples containing the degrees of each node in each snapshot
Making copies and subgraphs
SnapshotGraph.subgraph(nbunch[, sbunch]) Return a snapshot graph containing only the nodes in bunch, and snapshot indexes in sbunch.
SnapshotGraph.to_directed([sbunch]) Returns a list of networkx directed graph objects.
SnapshotGraph.to_undirected([sbunch]) Returns a list of networkx graph objects.

Developer Guide

DyNetworkX is still under development and the repository is kept private. If you are interested in getting access to the project as a developer, go to Need Help? for contact information.

License

BSD 3-Clause License

Copyright (c) 2018, IDEAS Lab @ The University of Toledo.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Need Help?

If you have any trouble with DyNetworkX, please email Makan.Arastuie@rockets.utoledo.edu

Indices and tables