In [1]:
from IPython.display import HTML

HTML('''<script>
code_show=true; 
function code_toggle() {
 if (code_show){
 $('div.input').hide();
 } else {
 $('div.input').show();
 }
 code_show = !code_show
} 
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()"><input type="submit" value="Click here to toggle on/off the raw code."></form>''')
Out[1]:
In [2]:
from IPython.display import Image
Image(filename='split/sdgmn3_Page-0.png')
Out[2]:

The Python scripts for all the computations displayed here are available at:

https://github.com/mboudour/GraphMultilayerity

In [3]:
Image(filename='split/sdgmn3_Page-1.png')
Out[3]:
In [4]:
Image(filename='split/sdgmn3_Page-2.png')
Out[4]:
In [5]:
Image(filename='split/sdgmn3_Page-3.png')
Out[5]:
In [6]:
Image(filename='split/sdgmn3_Page-4.png')
Out[6]:
In [7]:
Image(filename='split/sdgmn3_Page-5.png')
Out[7]:
In [8]:
Image(filename='split/sdgmn3_Page-6.png')
Out[8]:

A Sierpinski (Fractal) Self-Similar Graph

In [9]:
%matplotlib inline
In [10]:
run SierpinskiCantorGraph.py
In [11]:
Image(filename='split/sdgmn3_Page-7.png')
Out[11]:
In [12]:
Image(filename='split/sdgmn3_Page-8.png')
Out[12]:
In [13]:
Image(filename='split/sdgmn3_Page-9.png')
Out[13]:
In [14]:
Image(filename='split/sdgmn3_Page-10.png')
Out[14]:
In [15]:
Image(filename='split/sdgmn3_Page-11.png')
Out[15]:
In [16]:
Image(filename='split/sdgmn3_Page-12.png')
Out[16]:
In [17]:
Image(filename='split/sdgmn3_Page-13.png')
Out[17]:


EXAMPLES

1. A Random Bipartite Graph
2. Synthetic 3-Layer Graphs in the Triangular Topology
3. Synthetic 3-Layer Graphs in the 2-Path Topology
4. Analytic 3-Layer Graphs in the Triangular Topology
5. Analytic 3-Layer Graphs in the 2-Path Topology
6. Temporal Graphs with 3 Slices


1. A Random Bipartite Graph

In [18]:
from bipartite_comm import *
n=7
m=6
p=0.19
G,layer1,layer2,layer3,slayer1,slayer2,edgeList,partition=create_3comms_bipartite(n,m,p)
pos,fig=plot_initial_bgraph(G)
create_colors_per_comm(G,layer1,layer2,layer3,slayer1,slayer2,pos,fig)
n = 7
m = 5
Number of edges = 11
Community1 =  [0, 6, 8]
Community2 =  [1, 4, 5, 10, 12]
Community3 =  [2, 3, 7, 9]

In [19]:
broken_graph,broken_partition,npartition ,fig= create_node_3attri_graph(G,layer1,layer2,layer3,slayer1,slayer2)
plot_graph_bip_3comms_2set(G,broken_graph,broken_partition,npartition,layer1,layer2,layer3,fig,d1=1.4,d2=5.,d3=0.8,withlabels=False,nodesize=100,layout=False)
broken_graph,broken_partition,npartition=create_node_2attri_graph(G,layer1,layer2,layer3,slayer1,slayer2)
plot_graph_bip_2set_3comms(G,broken_graph,broken_partition,npartition,slayer1,slayer2,layer3,fig,d1=1.4,d2=5.,d3=0.8,withlabels=False,nodesize=100,layout=False)
In [20]:
from bipartite_comm import *
n=10
m=10
p=0.23
G,layer1,layer2,layer3,slayer1,slayer2,edgeList,partition=create_3comms_bipartite(n,m,p)
pos,fig=plot_initial_bgraph(G,subp=131)
create_colors_per_comm(G,layer1,layer2,layer3,slayer1,slayer2,pos,fig,subp=132)
create_2colors_per_comm(G,layer1,layer2,layer3,slayer1,slayer2,pos,fig,subp=133)
n = 10
m = 10
Number of edges = 25
Community1 =  [0, 1, 3, 5, 7, 10, 11, 16, 17, 18]
Community2 =  [2, 12, 19]
Community3 =  [4, 6, 8, 9, 13, 14, 15]

In [21]:
broken_graph,broken_partition,npartition ,fig=create_node_6attri_graph(G,layer1,layer2,layer3,slayer1,slayer2)
plot_graph_bip_3comms_2set(G,broken_graph,broken_partition,npartition,layer1,layer2,layer3,fig,asso=False,d1=1.4,d2=5.,d3=0.8,withlabels=False,nodesize=100,layout=False)

2. Synthetic 3-Layer Graphs in the Triangular Topology

In [22]:
%matplotlib inline
from syntheticThreeLayerGraph import synthetic_three_level, plot_graph

n1=n2=n3=50
p1=p2=p3=0.01
q1=q2=q3=0.01

G,J,FF,DD,edgeList = synthetic_three_level(n1,n2,n3,p1,p2,p3,q1,q2,q3,no_isolates=False)
pos=plot_graph(G,J,FF,DD,n1,n2,n3,d1=1,d2=10.,d3=0.8,nodesize=50,withlabels=False,edgelist=edgeList,layout=False,b_alpha=0.25)
In [23]:
from threeLayerCommunityParition import create_node_comm_graph, plot_graph

broken_graph,broken_partition,npartition ,G= create_node_comm_graph(G,J.nodes(),FF.nodes(),DD.nodes())
plot_graph(G,broken_graph,broken_partition,npartition,J.nodes(),FF.nodes(),DD.nodes(),d1=1.4,d2=5.,d3=0.8,withlabels=False,nodesize=100,layout=False)
In [24]:
from threeLayerConnComponentsPartition import create_node_conncomp_graph, plot_graph

broken_graph,broken_partition,npartition,G = create_node_conncomp_graph(G,J.nodes(),FF.nodes(),DD.nodes())
plot_graph(G,broken_graph,broken_partition,npartition,J.nodes(),FF.nodes(),DD.nodes(),d1=1.4,d2=5.,d3=0.8,withlabels=False,nodesize=100,layout=False)
In [25]:
from threeLayer3AttributesPartition import create_node_3attri_graph, plot_graph

r1=r2=r3=0.333

broken_graph,broken_partition,npartition,G = create_node_3attri_graph(G,J.nodes(),FF.nodes(),DD.nodes(),r1,r2,r3)
plot_graph(G,broken_graph,broken_partition,npartition,J.nodes(),FF.nodes(),DD.nodes(),d1=1.4,d2=5.,d3=0.8,withlabels=False,nodesize=100,layout=False)

3. Synthetic 3-Layer Graphs in the 2-Path Topology

In [26]:
from syntheticThreeLayerGraph_l import synthetic_three_level, plot_graph

n1=n2=n3=50
p1=p2=p3=0.01
q1=q2=q3=0.01

G,J,FF,DD,edgeList = synthetic_three_level(n1,n2,n3,p1,p2,p3,q1,q2,q3,no_isolates=False)
pos=plot_graph(G,J,FF,DD,n1,n2,n3,d1=2,d2=3.,nodesize=50,withlabels=False,edgelist=edgeList,layout=False,b_alpha=0.25)
In [27]:
from threeLayerCommunityParition import create_node_comm_graph, plot_graph_stack

broken_graph,broken_partition,npartition,G = create_node_comm_graph(G,J.nodes(),FF.nodes(),DD.nodes())
plot_graph_stack(G,broken_graph,broken_partition,npartition,J.nodes(),FF.nodes(),DD.nodes(),d1=1.4,d2=5.,d3=0.8,withlabels=False,nodesize=100,layout=False)
In [28]:
from threeLayerConnComponentsPartition import create_node_conncomp_graph, plot_graph_stack

broken_graph,broken_partition,npartition,G = create_node_conncomp_graph(G,J.nodes(),FF.nodes(),DD.nodes())
plot_graph_stack(G,broken_graph,broken_partition,npartition,J.nodes(),FF.nodes(),DD.nodes(),d1=1.4,d2=5.,d3=0.8,withlabels=False,nodesize=100,layout=False)
In [29]:
from threeLayer3AttributesPartition import create_node_3attri_graph, plot_graph_stack

r1=r2=r3=0.333

broken_graph,broken_partition,npartition,G = create_node_3attri_graph(G,J.nodes(),FF.nodes(),DD.nodes(),r1,r2,r3)
plot_graph_stack(G,broken_graph,broken_partition,npartition,J.nodes(),FF.nodes(),DD.nodes(),d1=1.4,d2=5.,d3=0.8,withlabels=False,nodesize=100,layout=False)

4. Analytic 3-Layer Graphs in the Triangular Topology

In [30]:
from analyticThreeLayerGraph import analyticThreeLayerGraph, plot_graph

n = 150
p = 0.01
r1 = r2 = r3 = 0.333

G, layer1, layer2, layer3, edgeList = analyticThreeLayerGraph(n,p,r1,r2,r3,G_isolates=True)
plot_graph(G,layer1,layer2,layer3,d1=1.5,d2=5.,d3=0.8,nodesize=100,withlabels=False,edgelist=edgeList,layout=False,alpha=0.25)
In [31]:
from threeLayerCommunityParition import create_node_comm_graph, plot_graph

broken_graph,broken_partition,npartition,G = create_node_comm_graph(G,layer1,layer2,layer3)
plot_graph(G,broken_graph,broken_partition,npartition,layer1,layer2,layer3,d1=1.4,d2=5.,d3=0.8,withlabels=False,nodesize=100,layout=False)
In [32]:
from threeLayerConnComponentsPartition import create_node_conncomp_graph, plot_graph

broken_graph,broken_partition,npartition,G = create_node_conncomp_graph(G,layer1,layer2,layer3)
plot_graph(G,broken_graph,broken_partition,npartition,layer1,layer2,layer3,d1=1.4,d2=5.,d3=0.8,withlabels=False,nodesize=100,layout=False)
In [33]:
from threeLayer3AttributesPartition import create_node_3attri_graph, plot_graph

r1=r2=r3=0.333

broken_graph,broken_partition,npartition,G = create_node_3attri_graph(G,layer1,layer2,layer3,r1,r2,r3)
plot_graph(G,broken_graph,broken_partition,npartition,layer1,layer2,layer3,d1=1.4,d2=5.,d3=0.8,withlabels=False,nodesize=100,layout=False)

5. Analytic 3-Layer Graphs in the 2-Path Topology

In [34]:
from analyticThreeLayerGraph_l import analyticThreeLayerGraph, plot_graph

n = 150
p = 0.01
r1 = 0.333
r2 = 0.333
r3 = 0.333

G, layer1, layer2, layer3, edgeList = analyticThreeLayerGraph(n,p,r1,r2,r3,G_isolates=True)
plot_graph(G,layer1,layer2,layer3,d1=3.5,d2=5.,d3=0.8,nodesize=100,withlabels=False,edgelist=edgeList,layout=False,alpha=0.2)
In [35]:
from threeLayerCommunityParition import create_node_comm_graph, plot_graph_stack

broken_graph,broken_partition,npartition,G = create_node_comm_graph(G,J.nodes(),FF.nodes(),DD.nodes())
plot_graph_stack(G,broken_graph,broken_partition,npartition,J.nodes(),FF.nodes(),DD.nodes(),d1=1.4,d2=5.,d3=0.8,withlabels=False,nodesize=100,layout=False)
In [36]:
from threeLayerConnComponentsPartition import create_node_conncomp_graph, plot_graph_stack

broken_graph,broken_partition,npartition,G = create_node_conncomp_graph(G,J.nodes(),FF.nodes(),DD.nodes())
plot_graph_stack(G,broken_graph,broken_partition,npartition,J.nodes(),FF.nodes(),DD.nodes(),d1=1.4,d2=5.,d3=0.8,withlabels=False,nodesize=100,layout=False)
In [37]:
from threeLayer3AttributesPartition import create_node_3attri_graph, plot_graph_stack

r1=r2=r3=0.333

broken_graph,broken_partition,npartition,G = create_node_3attri_graph(G,J.nodes(),FF.nodes(),DD.nodes(),r1,r2,r3)
plot_graph_stack(G,broken_graph,broken_partition,npartition,J.nodes(),FF.nodes(),DD.nodes(),d1=1.4,d2=5.,d3=0.8,withlabels=False,nodesize=100,layout=False)

6. Temporal Graph with 3 Slices

In [38]:
%matplotlib inline
from syntheticThreeLayerGraph_time import synthetic_three_level, plot_graph

p1=p2=p3=0.1
n=50
G,J,FF,DD,JFD,edgeList = synthetic_three_level(n,p1,p2,p3,J_isolates=True,F_isolates=True,D_isolates=True)
#print edgeList
created_pos=plot_graph(n,G,J,FF,DD,JFD,d1=2.,d2=3.,nodesize=50,withlabels=False,edgelist=edgeList,layout=False,b_alpha=0.05) #d=0.5 #d
In [39]:
from threeLayerCommunityParition import create_node_comm_graph, plot_graph_stack

broken_graph,broken_partition,npartition,G = create_node_comm_graph(G,J.nodes(),FF.nodes(),DD.nodes())
plot_graph_stack(G,broken_graph,broken_partition,npartition,J.nodes(),FF.nodes(),DD.nodes(),d1=1.4,d2=5.,d3=0.8,withlabels=False,nodesize=100,layout=False)
In [40]:
from threeLayerConnComponentsPartition import create_node_conncomp_graph, plot_graph_stack

broken_graph,broken_partition,npartition,G = create_node_conncomp_graph(G,J.nodes(),FF.nodes(),DD.nodes())
plot_graph_stack(G,broken_graph,broken_partition,npartition,J.nodes(),FF.nodes(),DD.nodes(),d1=1.4,d2=5.,d3=0.8,withlabels=False,nodesize=100,layout=False)
In [41]:
from threeLayer3AttributesPartition import create_node_3attri_graph, plot_graph_stack

r1=r2=r3=0.333

broken_graph,broken_partition,npartition,G = create_node_3attri_graph(G,J.nodes(),FF.nodes(),DD.nodes(),r1,r2,r3)
plot_graph_stack(G,broken_graph,broken_partition,npartition,J.nodes(),FF.nodes(),DD.nodes(),d1=1.4,d2=5.,d3=0.8,withlabels=False,nodesize=100,layout=False)
In [41]: