Example #1
0
def create_TemporalGraph():
    """create a graph"""
    g = TemporalPropertyGraph()
    g1 = PropertyGraph()
    g2 = PropertyGraph()
    g3 = PropertyGraph()
    # -- Adding vertices to 'PropertyGraph'
    dict_0, dict_1, dict_2 = {}, {}, {}
    for i in range(2):
        g1.add_vertex()
    for i in range(5):
        g2.add_vertex()
    for i in range(13):
        g3.add_vertex()
    # -- Adding STRUCTURAL edges to 'PropertyGraph'
    g1.add_edge(0, 1)
    for i in range(4):
        g2.add_edge(i, i + 1)
    g2.add_edge(1, 3)
    for i in range(12):
        g3.add_edge(i, i + 1)
    g3.add_edge(0, 3)
    g3.add_edge(2, 6)
    g3.add_edge(3, 6)
    g3.add_edge(4, 6)
    g3.add_edge(8, 10)
    g3.add_edge(10, 12)
    # -- Creating lineage: TEMPORAL edges
    L12 = {0: [0, 1, 2], 1: [3, 4]}
    L23 = {0: [0, 1], 1: [2], 2: [3, 4, 5, 6], 3: [7, 8], 4: [9, 10, 11, 12]}
    # -- Extending TemporalPropertyGraph with structural graph ('PropertyGraph') and linking them with lineage information.
    g.extend([g1, g2, g3], [L12, L23])
    return g
def create_TemporalGraph_GraphProperty( set_as_ids = True ):
    """create a TemporalGraph with extra 'graph_property' to test relabbeling of keys and labels as ids"""
    g = TemporalPropertyGraph()
    g1 = PropertyGraph()
    g2 = PropertyGraph()
    g3 = PropertyGraph()
    # -- Adding vertices to 'PropertyGraph'
    dict_1, dict_2, dict_3 ={}, {}, {}
    for i in range(2):
        g1.add_vertex()
        dict_1[i]="t1_vid_"+str(i)
    g1.add_graph_property('time-point_vid',dict_1)
    for i in range(5):
        g2.add_vertex()
        dict_2[i]="t2_vid_"+str(i)
    g2.add_graph_property('time-point_vid',dict_2)
    for i in range(13):
        g3.add_vertex()
        dict_3[i]="t3_vid_"+str(i)
    g3.add_graph_property('time-point_vid',dict_3)
    # -- Setting keys to vid type: will be relabelled when creating the TPG 
    if set_as_ids:
        g1.set_graph_property_key_to_vid_type('time-point_vid')
        g2.set_graph_property_key_to_vid_type('time-point_vid')
        g3.set_graph_property_key_to_vid_type('time-point_vid')
    # -- Adding STRUCTURAL edges to 'PropertyGraph'
    g1.add_edge(0,1)
    for i in range(4):
        g2.add_edge(i, i+1)
    g2.add_edge(1,3)
    for i in range(12):
        g3.add_edge(i, i+1)
    g3.add_edge(0,3)
    g3.add_edge(2,6)
    g3.add_edge(3,6)
    g3.add_edge(4,6)
    g3.add_edge(8,10)
    g3.add_edge(10,12)
    # -- Creating lineage: TEMPORAL edges
    L12={
        0 : [0, 1, 2],
        1 : [3, 4]
        }
    L23={
        0 : [0, 1],
        1 : [2],
        2 : [3, 4, 5, 6],
        3 : [7, 8],
        4 : [9, 10, 11, 12]
        }
    # -- Extending TemporalPropertyGraph with structural graph ('PropertyGraph') and linking them with lineage information.
    g.extend([g1, g2, g3], [L12, L23])
    return g
def create_TemporalGraph_partial_lineage():
    """
    Create a TemporalPropertyGraph with partial lineage.
    Simulate partial lost of lineage du to daughter cells being out of the acquisition frame.

    Here the is no daughters for TPG_vertex_id #6 (cell_id #4 in g2).
    """
    g = TemporalPropertyGraph()
    g1 = PropertyGraph()
    g2 = PropertyGraph()
    g3 = PropertyGraph()
    # -- Adding vertices to 'PropertyGraph'
    dict_0, dict_1, dict_2 ={}, {}, {}
    for i in range(2):
        g1.add_vertex()
    for i in range(5):
        g2.add_vertex()
    for i in range(13):
        g3.add_vertex()
    # -- Adding STRUCTURAL edges to 'PropertyGraph'
    g1.add_edge(0,1)
    for i in range(4):
        g2.add_edge(i, i+1)
    g2.add_edge(1,3)
    for i in range(12):
        g3.add_edge(i, i+1)
    g3.add_edge(0,3)
    g3.add_edge(2,6)
    g3.add_edge(3,6)
    g3.add_edge(4,6)
    g3.add_edge(8,10)
    g3.add_edge(10,12)
    # -- Creating lineage: TEMPORAL edges
    L12={
        0 : [0, 1, 2],
        1 : [3, 4]
        }
    L23={
        0 : [0, 1],
        1 : [2],
        2 : [3, 4, 5, 6],
        3 : [7, 8],
        }
    # -- Extending TemporalPropertyGraph with structural graph ('PropertyGraph') and linking them with lineage information.
    g.extend([g1, g2, g3], [L12, L23])
    return g
Example #4
0
def create_TemporalGraph_GraphProperty(set_as_ids=True):
    """create a TemporalGraph with extra 'graph_property' to test relabbeling of keys and labels as ids"""
    g = TemporalPropertyGraph()
    g1 = PropertyGraph()
    g2 = PropertyGraph()
    g3 = PropertyGraph()
    # -- Adding vertices to 'PropertyGraph'
    dict_1, dict_2, dict_3 = {}, {}, {}
    for i in range(2):
        g1.add_vertex()
        dict_1[i] = "t1_vid_" + str(i)
    g1.add_graph_property('time-point_vid', dict_1)
    for i in range(5):
        g2.add_vertex()
        dict_2[i] = "t2_vid_" + str(i)
    g2.add_graph_property('time-point_vid', dict_2)
    for i in range(13):
        g3.add_vertex()
        dict_3[i] = "t3_vid_" + str(i)
    g3.add_graph_property('time-point_vid', dict_3)
    # -- Setting keys to vid type: will be relabelled when creating the TPG
    if set_as_ids:
        g1.set_graph_property_key_to_vid_type('time-point_vid')
        g2.set_graph_property_key_to_vid_type('time-point_vid')
        g3.set_graph_property_key_to_vid_type('time-point_vid')
    # -- Adding STRUCTURAL edges to 'PropertyGraph'
    g1.add_edge(0, 1)
    for i in range(4):
        g2.add_edge(i, i + 1)
    g2.add_edge(1, 3)
    for i in range(12):
        g3.add_edge(i, i + 1)
    g3.add_edge(0, 3)
    g3.add_edge(2, 6)
    g3.add_edge(3, 6)
    g3.add_edge(4, 6)
    g3.add_edge(8, 10)
    g3.add_edge(10, 12)
    # -- Creating lineage: TEMPORAL edges
    L12 = {0: [0, 1, 2], 1: [3, 4]}
    L23 = {0: [0, 1], 1: [2], 2: [3, 4, 5, 6], 3: [7, 8], 4: [9, 10, 11, 12]}
    # -- Extending TemporalPropertyGraph with structural graph ('PropertyGraph') and linking them with lineage information.
    g.extend([g1, g2, g3], [L12, L23])
    return g
Example #5
0
def create_TemporalGraph_partial_lineage():
    """
    Create a TemporalPropertyGraph with partial lineage.
    Simulate partial lost of lineage du to daughter cells being out of the acquisition frame.

    Here the is no daughters for TPG_vertex_id #6 (cell_id #4 in g2).
    """
    g = TemporalPropertyGraph()
    g1 = PropertyGraph()
    g2 = PropertyGraph()
    g3 = PropertyGraph()
    # -- Adding vertices to 'PropertyGraph'
    dict_0, dict_1, dict_2 = {}, {}, {}
    for i in range(2):
        g1.add_vertex()
    for i in range(5):
        g2.add_vertex()
    for i in range(13):
        g3.add_vertex()
    # -- Adding STRUCTURAL edges to 'PropertyGraph'
    g1.add_edge(0, 1)
    for i in range(4):
        g2.add_edge(i, i + 1)
    g2.add_edge(1, 3)
    for i in range(12):
        g3.add_edge(i, i + 1)
    g3.add_edge(0, 3)
    g3.add_edge(2, 6)
    g3.add_edge(3, 6)
    g3.add_edge(4, 6)
    g3.add_edge(8, 10)
    g3.add_edge(10, 12)
    # -- Creating lineage: TEMPORAL edges
    L12 = {0: [0, 1, 2], 1: [3, 4]}
    L23 = {
        0: [0, 1],
        1: [2],
        2: [3, 4, 5, 6],
        3: [7, 8],
    }
    # -- Extending TemporalPropertyGraph with structural graph ('PropertyGraph') and linking them with lineage information.
    g.extend([g1, g2, g3], [L12, L23])
    return g
def create_TemporalGraph():
    """create a graph"""
    g = TemporalPropertyGraph()
    g1 = PropertyGraph()
    g2 = PropertyGraph()
    g3 = PropertyGraph()
    # -- Adding vertices to 'PropertyGraph'
    dict_0, dict_1, dict_2 ={}, {}, {}
    for i in range(2):
        g1.add_vertex()
    for i in range(5):
        g2.add_vertex()
    for i in range(13):
        g3.add_vertex()
    # -- Adding STRUCTURAL edges to 'PropertyGraph'
    g1.add_edge(0,1)
    for i in range(4):
        g2.add_edge(i, i+1)
    g2.add_edge(1,3)
    for i in range(12):
        g3.add_edge(i, i+1)
    g3.add_edge(0,3)
    g3.add_edge(2,6)
    g3.add_edge(3,6)
    g3.add_edge(4,6)
    g3.add_edge(8,10)
    g3.add_edge(10,12)
    # -- Creating lineage: TEMPORAL edges
    L12={
        0 : [0, 1, 2],
        1 : [3, 4]
        }
    L23={
        0 : [0, 1],
        1 : [2],
        2 : [3, 4, 5, 6],
        3 : [7, 8],
        4 : [9, 10, 11, 12]
        }
    # -- Extending TemporalPropertyGraph with structural graph ('PropertyGraph') and linking them with lineage information.
    g.extend([g1, g2, g3], [L12, L23])
    return g
def create_random_TPG():
    import random
    g = TemporalPropertyGraph()
    # -- First, we create 'PropertyGraph':
    p1, p2 = PropertyGraph(), PropertyGraph()
    vids = range(1,10)
    edges = []
    for i in vids:
        l = range((i+1),10)
        random.shuffle(l)
        for j in l[:3]:
            edges.append((i,j))
    mapping = dict((vid,[vid]) for vid in vids)
    for v in vids:
        p1.add_vertex(v)
        p2.add_vertex(v)
    for s,t in edges:
        p1.add_edge(s,t)
        p2.add_edge(s,t)
    # -- Then we can create the 'TemporalPropertyGraph':
    g.extend([p1,p2],[mapping])
    return g
Example #8
0
def create_random_TPG():
    import random
    g = TemporalPropertyGraph()
    # -- First, we create 'PropertyGraph':
    p1, p2 = PropertyGraph(), PropertyGraph()
    vids = range(1, 10)
    edges = []
    for i in vids:
        l = range((i + 1), 10)
        random.shuffle(l)
        for j in l[:3]:
            edges.append((i, j))
    mapping = dict((vid, [vid]) for vid in vids)
    for v in vids:
        p1.add_vertex(v)
        p2.add_vertex(v)
    for s, t in edges:
        p1.add_edge(s, t)
        p2.add_edge(s, t)
    # -- Then we can create the 'TemporalPropertyGraph':
    g.extend([p1, p2], [mapping])
    return g
def test_import_TPG_from_networkx():
    """ Create a random graph and import it to networkx """
    g = create_random_TPG()
    nxg = g.to_networkx()
    gg = TemporalPropertyGraph().from_networkx(nxg)