Estrangement Confinement

Contents:

EstrangementDemo

Script demonstrating the use of the estrangement library to detect and visualize temporal communities.

EstrangementDemo.detect_and_plot_temporal_communities()

Function to run simulations, based on a specified dataset, and created tiled plots of the temporal communities.

Parameters can be specified at the command line, when calling this script. Alternatively, a config file specifed at the command line can be used to set the parameter. At the very minimum, a path to the data set must be specified.

Each experiment requires a name, which is used to create a folder to store the results of the simulation. If the results already exist in the folder specified by the experiment name, plots are created using these existing results and the simulation is not run on subsequent calls to EstrangementDemo.py. To run the simulation again, delete the experiment folder before running this script, or use a different experiment name.

Examples

>>> # To see all configuarable parameters use the -h option 
>>> EstrangementDemo.py -h
>>> # Configurable parameters can be specified at the command line
>>> EstrangementDemo.py --dataset_dir ./data --display_on True --exp_name my_experiment
>>> # A config file can be used, but it must be preceeded by an '@'
>>> # Three config files are provided as examples, check that that path to the dataset is valid.
>>> EstrangementDemo.py @senate.conf
>>> EstrangementDemo.py @markovian.conf
>>> EstrangementDemo.py @realitymining.conf 

Estrangement

This module implements the Estrangement Confinement Algorithm (ECA) and various functions necessary to read the input snapshots, process information and return the results and/or print them to file.

Estrangement.estrangement.make_Zgraph(g0, g1, g0_label_dict)

Constructs and returns the Zgraph, as defined in Eq 3 of the paper.

Parameters :

g0, g1: networkx.Graph :

The previous and the current network snapshot, respectively

g0_label_dict: dictionary {node:community} :

Cpmmunity labels for the nodes in g0 (the previous snapshot)

Returns :

Z: graph :

The Zgraph

Examples

>>> g0 = nx.Graph()
>>> g0.add_edges_from([(1,2,{'weight':2}),(1,3,{'weight':1}),(2,4,{'weight':1})])
>>> g1 = nx.Graph()
>>> g1.add_edges_from([(1,2,{'weight':2}),(1,3,{'weight':1}),(3,4,{'weight':1})])
>>> labels = {1:'b',2:'b',3:'b',4:'b',5:'b',6:'b'}
>>> print(make_Zgraph(g0,g1,labels)
Estrangement.estrangement.read_general(datadir, tolerance, minrepeats)

Function to read datasets from files in datadir.

Each file represents a graph for a particular timestamp. The name of the files is expected to be <timestamp>.ncol, and each line in the file represents one edge in the graph e.g. line:’ 1 2 5 ‘ indicates there is an edge between nodes ‘1’ and ‘2’ with weight ‘5’

Parameters :

datadir: string :

path to the directory containing the dataset.

tolerance: float,optional :

For a label to be considered a dominant label, it must be within this much of the maximum value found for the quality function. The smaller it is, the fewer dominant labels there will be.

minrepeats: integer :

The number of variations to try before returning the best partition.

Returns :

t: list :

an array of timestamps, each representing a snapshot of the communities.

g1: networkx.Graph :

the last graph to be read from file.

initial_label_dictionary: dictionary { node: community} :

A dictionary mapping nodes to community labels if it is the first snapshot, otherwise None.

Estrangement.estrangement.maxQ(g1, tolerance=1e-05, minrepeats=10)

Function which returns the partitioning of the input graph, into communities, which maximizes the value of the quality function Q.

In this case, the quality function is modularity. See, [Blondel08] for more details. Note that estrangement is not taken into cosideration in this calculation. This is only used for computing a partition for the intial snapshot.

Parameters :

g1: networkx.Graph :

The input graph.

minrepeats: integer, optional :

The number of variations to try before returning the best partition.

tolerance: float, optional :

For a label to be considered a dominant label, it must be within this much of the maximum value found for the quality function. The smaller it is, the fewer dominant labels there will be.

Returns :

dictPartition: dictionary {node:community} :

The partitioning which results in the best value of the quality function: Q (modularity).

Examples

>>> g0 = nx.Graph
>>> g0.add_edges_from([(1,2,{'weight':2}),(1,3,{'weight':1}),(2,4,{'weight':1})])
>>> print(maxQ(g0,minrepeats=10))
Estrangement.estrangement.repeated_runs(g1, delta, tolerance, lambduh, Zgraph, repeats)

Function to make repeated calls to the Label Propagation Algorithm (LPA) and store the values of Q, E and F, as well as the corresponding partitioning for later use. F is the Lagrangian, referred to in the paper as L.

Parameters :

g1: networkx graph :

The input graph

delta: float :

The temporal divergence. Smaller values imply greater emphasis on temporal contiguity whereas larger values place greater emphasis on finding better instanteous communities.

tolerance: float :

For a label to be considered a dominant label, it must be within this much of the maximum value found for the quality function. The smaller the value of tolerance, the fewer dominant labels there will be.

Zgraph: networkx graph :

Graph where each edges join nodes belonging to the same community over previous snapshots

repeats: integer :

The number of calls made to best partition to best_parition.

Returns :

dictPartition: List of dictionaries representing community labeling :

dictQ: List of values of Q corresponding to the above labeling dictE: List of values of E corresponding to the above labeling dictF: List of values of F corresponding to the above labeling

Examples

>>> g0 = nx.Graph()
>>> g0.add_edges_from([(1,2,{'weight':1}),(2,3,{'weight':1}),(1,3,{'weight':1}),(3,4,{'weight':1}),(4,5,{'weight':1}),(4,6,{'weight':1}),(5,7,{'weight':1}),(6,7,{'weight':1}),(8,9,{'weight':1}),(8,10,{'weight':1}),(9,10,{'weight':1})])
>>> dictPartition,dictQ,DictE,DictF = estrangement.repeated_runs(g0, delta=0.05, tolerance=0.01, lambduh=1,g0,repeats = 3)
Estrangement.estrangement.ECA(dataset_dir='./data', results_filename='matched_labels.log', tolerance=1e-05, convergence_tolerance=0.01, delta=0.05, minrepeats=10, increpeats=10, maxfun=500, write_stats=False)

The Estrangement Reduction Algorithm, as decribed in: [KS12]. This function detects temporal communities and returns the results.

Parameters :

dataset_dir: string :

Path to the relevant dataset files

results_filename: string :

The resulting community partition is written to this file. It is a dictionary of the form: {time : {node : label}}

tolerance: float, optional :

For a label to be considered a dominant label, it must be within this much of the maximum value found for the quality function. The smaller it is, the fewer dominant labels there will be.

convergence_tolerance: float,optional :

The convergence tolerance used in optimizing the value of lambda.

delta: float :

The temporal divergence. Smaller values imply greater emphasis on temporal contiguity whereas larger values place greater emphasis on finding better instanteous communities.

minrepeats: integer,optional :

The number of times to call LPA. Each call increases the likilhood of finding the optimal partition, however, such a partition may be found with few calls depending on the graph.

increpeats: integer,optional :

The size of a step in the LPA.

maxfun: integer, optional :

The maximum number of function calls made to optimize lambda.

write_stats, optional :

If ‘True’, the stats are written to files named <stat>.log These logs are not needed to plot temporal communities but are needed to plot other stats.

Returns :

matched_labels : dictionary {time: {node:label}}

The labelling of each node for each snapshot

References

[KS12](1, 2) Vikas Kawadia and Sameet Sreenivasan, ``Sequential detection of temporal communities by estrangement confinement ,’’ in Nature Scientific Reports, Nov 2012, http://www.nature.com/srep/2012/121109/srep00794/full/srep00794.html

Examples

>>> ECA(dataset_dir='tests/sample_data',delta=0.001)

Agglomerate

This module implements community detection using an agglomerative approach as decribed in [Blondel08]. It has been modified for estrangement confinement. Tje original code is available here: http://perso.crans.org/aynaud/communities/

Estrangement.agglomerate.partition_at_level(dendogram, level)

Function which return the partition of the nodes at the given level.

A dendogram is a tree and each level is a partition of the graph nodes. Level 0 is the first partition, which contains the smallest communities, and the best partition is at height [len(dendogram) - 1]. The higher the level in the dendogram, the bigger the communities in that level. This function merely processes an existing dendogram, which is created by estrangement.agglomerate.generate_dendogram.

Parameters :

dendogram : list of dict

A list of partitions, i.e. dictionaries where keys at level (i+1) are the values at level i.

level : int

The level in the dendogram of the desired partitioning, which belongs to [0..len(dendogram)-1].

Returns :

partition : dictionary

A dictionary where keys are the nodes and the values are the set (community) to which it belongs.

Raises :

KeyError :

If the dendogram is not well formed or the level is greater than the height of the dendogram.

Examples

>>> G=nx.erdos_renyi_graph(100, 0.01)
>>> dendo = generate_dendogram(G)
>>> for level in range(len(dendo) - 1) :
>>>     print "partition at level", level, "is", partition_at_level(dendo, level)
Estrangement.agglomerate.modularity(partition, graph)

Function to compute the modularity of a partitioning of a graph, as defined in [Newman04].

Parameters :

partition : dictionary {node:community label}

The partition of the nodes, i.e a dictionary where keys are their nodes and values the communities.

graph : networkx.Graph

The graph showing the relationships between the nodes.

Returns :

modularity : float

The modularity of the graph, given the partition, see: [Newman04]

Raises :

KeyError: :

If the partition is not a partition of all graph nodes.

ValueError: :

If the graph has no link.

TypeError: :

If graph is not a networkx.Graph.

References

[Newman04](1, 2, 3) M.E.J. Newman and M. Girvan, “Finding and evaluating community structure in networks.” Physical Review E 69:26113 (2004).

Examples

>>> G=nx.erdos_renyi_graph(100, 0.01)
>>> part = best_partition(G)
>>> modularity(part, G)
Estrangement.agglomerate.best_partition(graph, delta, tolerance, lambduh, Zgraph, partition=None, q=<multiprocessing.queues.Queue object at 0x39af750>)

Function to compute the partition of the graph nodes which maximises the modularity (or tries to) using the Louvain heuristices.

This is the partition of highest modularity, i.e. the highest partition of the dendogram generated by the Louvain algorithm, see: [Blondel08]

Parameters :

graph : networkx.Graph

The networkx graph of the network.

tolerance: float :

For a label to be considered a dominant label, it must be within this much of the maximum value found for the quality function. The smaller it is, the fewer dominant labels there will be.

lambduh: float :

The Lagrange multiplier.

Zgraph : networkx.Graph

A graph containing edges between nodes of the same community in all previous snapshots.

partition: dictionary {node : community label}

The current labelling of the nodes in the graph.

q : multiprocessing.Queue

A queue used to store the results from multiple processes.

Returns :

partition : dictionnary {node

A dictionary which maps each node to a label (community) in the graph, which maximizes modularity.

References

[Blondel08](1, 2, 3, 4, 5, 6) Blondel, V.D. et al. Fast unfolding of communities in large networks. J. Stat. Mech 10008, 1-12(2008).

Examples

>>>  #Basic usage
>>> G=nx.erdos_renyi_graph(100, 0.01)
>>> part = best_partition(G)
>>> #other example to display a graph with its community :
>>> #better with karate_graph() as defined in networkx examples
>>> #erdos renyi don't have true community structure
>>> G = nx.erdos_renyi_graph(30, 0.05)
>>> #first compute the best partition
>>> partition = community.best_partition(G)
>>>  #drawing
>>> size = float(len(set(partition.values())))
>>> pos = nx.spring_layout(G)
>>> count = 0.
>>> for com in set(partition.values()) :
>>>     count = count + 1.
>>>     list_nodes = [nodes for nodes in partition.keys()
>>>                                 if partition[nodes] == com]
>>>     nx.draw_networkx_nodes(G, pos, list_nodes, node_size = 20,
                                node_color = str(count / size))
>>> nx.draw_networkx_edges(G,pos, alpha=0.5)
>>> plt.show()
Estrangement.agglomerate.generate_dendogram(graph, delta, tolerance, lambduh, Zgraph, part_init=None)

Function to find communities in a graph and return the associated dendogram.

A dendogram is a tree and each level is a partition of the graph nodes. Level 0 is the first partition, which contains the smallest communities, and the best is len(dendogram) - 1. The higher the level, the bigger the size of the communities. At each step, nodes (which are the communities from the previous step) are merged into aggregate communities such that modularity is maximized, subject to the estrangement constraint. For more details on the basic agglomerative procedure, see: [Blondel08].

Parameters :

graph : networkx.Graph

The networkx graph representing the network.

delta : float

The temporal divergence. Smaller values imply greater emphasis on temporal contiguity whereas larger values place greater emphasis on finding better instanteous communities.

tolerance: float :

For a label to be considered a dominant label, it must be within this much of the maximum value found for the quality function. The smaller it is, the fewer dominant labels there will be.

lambduh: float :

The Lagrange multiplier.

Zgraph : networkx.Graph

A graph containing edges between nodes of the same community in all previous snapshots The current labelling of the nodes in the graph

part_init : dictiionary, optional {node:community}

The algorithm will start using this partition of the nodes. It is a dictionary where keys are their nodes and values the communities.

Returns :

dendogram : list of dictionaries

A list of partitions, ie dictionnaries where keys of the i+1 are the values of the i, and where keys of the first are the nodes of graph.

Raises :

TypeError: :

If the graph is not a networkx.Graph

See also

best_partition

Notes

Uses Louvain algorithm: [Blondel08]

Examples

>>> G=nx.erdos_renyi_graph(100, 0.01)
>>> dendo = generate_dendogram(G)
>>> for level in range(len(dendo) - 1) :
>>>     print "partition at level", level, "is", partition_at_level(dendo, level)
Estrangement.agglomerate.induced_graph(partition, graph, zgraph)

Function to produce a graph where the nodes belonging to the same community are aggregated into a single node.

In the induced graph, there is a link of weight w between communities if the sum of the weights of the links between their elements is w. Communities are merged until there is no significant improvement on the objective function.

Parameters :

partition : dictionary {node:community}

A dictionary where keys are graph nodes and the values are the partition to which the node belongs.

graph : networkx.Graph

The current snapshot of the graph

Zgraph : networkx.Graph

A graph containing edges between nodes of the same community in all previous snapshots The current labelling of the nodes in the graph

Returns :

g : networkx.Graph

A networkx graph where nodes are the communities of the input graph.

Examples

>>> n = 5
>>> g = nx.complete_graph(2*n)
>>> part = dict([])
>>> for node in g.nodes() :
>>>     part[node] = node % 2
>>> ind = induced_graph(part, g)
>>> goal = nx.Graph()
>>> goal.add_weighted_edges_from([(0,1,n*n),(0,0,n*(n-1)/2), (1, 1, n*(n-1)/2)])
>>> nx.is_isomorphic(int, goal)
True

Label Propagation Algorithm

This module implements the Label Propagation Algorithm (LPAm) as decribed in: [Barber09].

Estrangement.lpa.lpa(G, tolerance=1e-05, lambduh=3.0, initial_label_dict=None, Z=<networkx.classes.graph.Graph object at 0x39c6290>)

Function to run the Label Propagation Algorithm and return the labelling upon convergence.

The Label Propagation algorithm initially assigns each node a unique label and sequentially allows nodes to change their label so as to maximize a specified objective function, which in this case is modularity.

Parameters :

G : networkx.Graph

The input graph.

tolerance: float, optional :

For a label to be considered a dominant label, it must be within this much of the maximum value found for the quality function. The smaller the value of tolerance, the fewer dominant labels there will be.

Z: networkx.Graph, optional :

The Z graph, see paper for details.

lambduh: :

The Lagrange multiplier.

initial_label_dict : dictionary {node_identifier:label}, optional

Initial labeling of the nodes in G. If no labelling is specified, each node is assigned a unique label.

Returns :

label_dict : dictionary {node_identifier:label}

Modified labeling after running the LPA on G.

Raises :

NetworkXError :

If the keys in the initial labelling does not match the nodes of the graph. If the number of iterations is greater than 4 times the number of edges in the graph.

See also

agglomerate.generate_dendogram

References

[Barber09](1, 2) M.J. Barber and J.W. Clark, “Detecting Network Communities by propagating labels under constraints.” Physical Review E 80:026129
[Raghavan07]U.N. Raghavan, R. Albert and S. Kumara, “Near linear time algorithm to detect community structure in large-scale networks.” Physical Review E 76:036106

Examples

>>> labeling = lpa.lpa(current_graph, tolerance, lambduh, Z=current_Zgraph)
>>> new_labeling = lpa.lpa(current_graph, tolerance, lambduh, labelling, Z=current_Zgraph)
>>> list(lpa.lpa(current_graph, tolerance, lambduh, Z=current_Zgraph))
[(0,1),(1,1),(2,2),(3,1)]

Plot Functions

This module implements functions used to produce evolution charts and other plots based on the output of estrangement confinement estrangement.estrangement.ECA .

Estrangement.plots.GetDeltas()

Function to scan for simulation folders in the current working directory and read the values of delta used in ECA.

The estrangement.estrangement.ECA function creates a folder specific to the value of delta used in each simulation (e.g. task_delta_0.01). Within each of these folders, a config file (simulation.conf) specifies the value of delta used in the simulation. This function reads the value of delta from each such config file and returns them in a list.

Alternatively, delta can be specified in the function calls, bypassing this function. See EstrangementDemo for more details.

Returns :

deltas : list

A list of float, where each member denotes a value of delta used in estrangement.estrangement.ECA.

Examples

>>> deltas = GetDeltas()
>>> print(deltas)
Estrangement.plots.plot_by_param(dictX, dictY, deltas=[], linewidth=2.0, markersize=15, label_fontsize=20, xfigsize=16.0, yfigsize=12.0, fontsize=28, fname=None, listLinestyles=None, xlabel='', ylabel='', title='', xscale='linear', yscale='linear', dictErr=None, display_on=False)

Given dictionaries, dictX with key=label, val = iterable of X values, and dictY with key=label, val = iterable of Y values, this function plots lines for each the labels specified on the same axes.

Parameters :

dictX : dictionary {label:[list of values]}

The X values of a set of lines to be plotted and their respective label.

dictY : dictionary {lable:[list of values]}

The Y values of a set of lines to be plotted and their respective label.

deltas : list of floats

The values of delta used for ECA for which there are results.

linewidth : float, optional

The desired font size of the lines to be plotted.

markersize : float, optional

The size of the markers used on each line.

label_fontsize : integer, optional

The size of the font used for the labels.

xfigsize : float, optional

The desired length of the x-axis.

yfigsize : float, optional

The desired length of the y-axis.

fontsize : integer, optional

The size of the font to be used in the figure.

fname : string, optional

The file is saved with this name.

listLinesstyles : list of strings, optional

A list consisting of the line styles to be used in the figures.

xlabel : string, optional

The label to appear on the x-axis.

ylabel : string, optional

The label to appear on the y-axis.

title : string, optional

The title of the figure.

xscale : string, optional

The type of scale to be used on the x-axis.

yscale : string, optional

The type of scale to be used on the y-axis.

dictErr : Dictionary {label:[list of values]}

Dictionary containing the Error Bars to be plotted on each line

display_on : boolean

If True, the graph is shown on the screen

Examples

>>> dictX = {'Estrangement:delta_0.05': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 'Estrangement:delta_0.025': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 'Estrangement:delta_0.01': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 'Estrangement:delta_1.0': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}
>>> dictY = {'Estrangement:delta_0.05': [0.0, 0.020202020202020204, 0.04040404040404041, 0.031578947368421054, 0.010309278350515464, 0.010101010101010102, 0.020202020202020204, 0.030612244897959183, 0.030303030303030304, 0.0103092783505154], 'Estrangement:delta_0.025': [0.0, 0.020202020202020204, 0.0, 0.021052631578947368, 0.0, 0.020202020202020204, 0.010101010101010102, 0.02040816326530612, 0.010101010101010102, 0.0], 'Estrangement:delta_0.01': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'Estrangement:delta_1.0': [0.061224489795918366, 0.020202020202020204, 0.04040404040404041, 0.05263157894736842, 0.0, 0.020202020202020204, 0.06060606060606061, 0.02040816326530612, 0.04040404040404041, 0.041237113402061855]}
>>> plot_by_param(dictX, dictY,deltas=[],fname='estrangement.svg', listLinestyles=['bs--', 'ro-',], xlabel="Time", ylabel='Estrangement', title="Estrangement")
Estrangement.plots.plot_function(listNames, image_extension='svg')

Plots a graph with the attributes specified in listNames.

This function relies on the file output of estrangement.estrangement.ECA. The value of the parameter write_stats should be set to True when calling estrangement.estrangement.ECA.

Parameters :

listNames : list of strings

Each string is an attribute to be plotted e.g. ‘Estrangement’,’Q’,’F’ etc.

image_extension : string, optional

The extension of the plot file to be saved.

Returns :

Nothing : The image is displayed on the screen and/or written to file.

Notes

The function reads the relevant input data from file and formats it. The actual plotting is done in estrangement.plots.plot_by_param.

Examples

>>> deltas = [0.01,0.025,0.05,1.0]
>>> for d in deltas:
...         estrangement.ECA(dataset_dir='../data',delta=d,increpeats=opt.increpeats,minrepeats=opt.minrepeats)
>>> plot_function(['Q', 'F',])
>>> plot_function(['Estrangement'])
Estrangement.plots.ChoosingDelta(image_extension='svg', deltas=[])

Function to plot avg(Q*-E) versus delta to get insights into the best delta for the given dataset.

This module merely processes the data, the plotting is done by estrangement.plots.plot_by_param. It requires the results from estrangement.estrangement.ECA to be outputted to file.

Parameters :

image_extension : string

The extension of the plot file to be saved

deltas : list of floats, optional

The values of deltas used in the simulation. If delta is not specifed, estrangement.plots.GetDeltas is called to create the list.

Returns :

Nothing : The plot is displayed on the screen and/or written to file.

Notes

To produce the necessary stat files, set ‘write_stats=True’ when calling estrangement.estrangement.ECA.

Examples

>>> deltas = [0.01,0.025,0.05,1.0]
>>> for d in deltas:
...         estrangement.ECA(dataset_dir='../data',delta=d,increpeats=opt.increpeats,minrepeats=opt.minrepeats)
>>> ChooseingDelta()
Estrangement.plots.preprocess_temporal_communities(matched_labels, deltas=[], nodes_of_interest=[], delta_to_use_for_node_ordering=1.0, label_sorting_keyfunc='random', nodeorder=None)

Function to perform the necessary preprocessing before making the tiled plots, of the temporal communities, for all simulation parameters.

Parameters :

matched_labels : dictionary {delta:{time: {node:label}}}

The labelling of each node for each snapshot.

deltas : list of floats, optional

The values of delta used in the simulation.

nodes of interest : list of integers, optional

If nodes_of_interest is not an empty list then show egocentric view of the evolution, meaning plot only the nodes which ever share a label with a node in the nodes_of_interest. If this list is empty, all nodes are plotted.

delta_to_use_for_node_ordering : float, optional

The value of delta used to order nodes for all temporal community plots.

label_sorting_keyfunc : string, optional

Method used to order the labels to be plotted.

Returns :

node_index_dict : dictionary {nodename:index_value}

A dictionary mapping nodenames to index values, which are to be plotted.

t_index_dict : dictionary {timestamp

A dictionary mapping timestamps/snapshot numbers to an index value, which are to be plotted.

label_index_dict : dictionary {label

A dictionary mapping community labels to an index value, which are to be plotted.

labels_of_interest_dict : dictionary {delta

Dictionary mapping delta to the labels of ‘nodes_of_interest’ for that delta.

Examples

>>> deltas = [0.01,0.025,0.05,1.0]
>>> for d in deltas:
...         estrangement.ECA(dataset_dir='../data',delta=d,increpeats=opt.increpeats,minrepeats=opt.minrepeats)
>>> node_index_dict, t_index_dict, label_index_dict, labels_of_interest_dict = preprocess_temporal_communities(
    nodes_of_interest=nodes_of_interest)
>>> print(node_index_dict)
>>> print(t_index_dict)   
Estrangement.plots.plot_temporal_communities(matched_labels, nodes_of_interest=[], deltas=[], tiled_figsize='(36, 16)', manual_colormap=None, label_cmap='Paired', frameon=True, xlabel='Time', ylabel='Node ID', label_fontsize=20, show_title=True, fontsize=28, colorbar=False, show_yticklabels=False, nodelabel_func=None, xtick_separation=5, snapshotlabel_func=None, wspace=0.2, bottom=0.1, image_extension='svg', dpi=200, display_on=True)

Module to create tiled plots, illustrating the temporal communities, for different values of paramters.

Parameters :

matched_labels : dictionary {delta

Dictionary containing the labelling of each node, at each snapshot for each value of delta.

nodes of interest : list of integers, optional

If nodes_of_interest is not an empty list then show egocentric view of the evolution, meaning plot only the nodes which ever share a label with a node in the nodes_of_interest. If this list is empty, all nodes are plotted.

deltas : list of floats, optional

The values of delta used for ECA for which there are results. This list can be derived from files created during simulation if it is not specified.

tiled_figsize : string, optional

Dimensions of the figure to be plotted.

manual_colormap : dictionary, optional

Maps labels to colors. If not specified, one is returned from ‘matlibplot.cm.get_cmap’.

label_cmap : string, optional

The name of a colors.Colormap instance, used by ‘matlibplot.cm.get_cmap’.

frameon : boolean, optional

If False, suppress drawing the figure frame in the subplots.

xlabel : string, optional

Label to appear on the x axis. This is set to ‘Time’ by default.

ylabel : string, optional

Label to appear on the y axis. This is set to ‘Node ID’ by default.

label_fontsize : integer, optional

The size of the font used for the labels. This is set to 20 by default.

show_title : boolean, optional

If False, the title of the figure is not displayed.

fontsize : integer, optional

The font size of the title.

colorbar : boolean, optional

Includes a color in the figure

show_y_ticklabels : boolean, False

If True, show tick labels on the y-axis

nodelabel_func : String, optional

The name of a function which maps node labels to indicies.

xtick_separation : integer, optional

The distance between ticks on the x-axis

snapshotlabel_func : string, optional

The name of a function to determine the ticks on the x-axis.

wspace : float, optional

The amount of width reserved for blank space between subplots

bottom : float, optional

The bottom of the subplots for ‘matlibplot.subplots_adjust’

image_extension : string, optional

The extension of plot file to be saved. This is “svg” by default.

dpi : integer, optional

The resolution of the plot. This is set to 200 dpi by default.

display_on : boolean, optional

If this is set to False, the plot is not displayed on the screen.

Returns :

Nothing, the plot is written to file and/or displayed on the screen depending on specified parameters. :

Examples

>>> deltas = [0.01,0.025,0.05,1.0]
>>> for d in deltas:
...         estrangement.ECA(dataset_dir='../data',delta=d,increpeats=opt.increpeats,minrepeats=opt.minrepeats)
>>> plot_temporal_communities() 
Estrangement.plots.plot_with_lambdas(linewidth=2.0, image_extension='svg')

Function to plot F with lambduhs for various snapshots.

Parameters :

linewidth : float, optional

The font size of the lines in the plot. This is set to 2.0 by default.

image_extension : string, optional

Specifies the extension of the plot file to be saved. The default image type is ‘.svg’

Returns :

Nothing. The plot is written to file. :

Examples

>>> deltas = [0.01,0.025,0.05,1.0]
>>> for d in deltas:
...         estrangement.ECA(dataset_dir='../data',delta=d,increpeats=opt.increpeats,minrepeats=opt.minrepeats)
>>> plot_with_lambdas()

Options Parser

Indices and tables

Table Of Contents

This Page