Example #1
0
def count_iso_4(G, sg, verbose=False):
    '''
    Given a set of 3 node indices in sg, obtains the subgraph from the
    original graph and renumbers the nodes from 0 to 2.
    It then matches this graph with one of the 13 graphs in
    directed_3.
    When it finds a match, it increments the motif_counts by 1 in the relevant
    index

    IMPORTANT: counts are stored in global motif_counts variable.
    It is reset at the beginning of the enumerate_subgraph method.
    '''
    if verbose:
        print(sg)
    nodes = snap.TIntV()
    for NId in sg:
        nodes.Add(NId)
    # This call requires latest version of snap (4.1.0)
    SG = snap.GetSubGraphRenumber(G, nodes)

    num_iters = len(directed_4)

    for i in range(len(directed_4)):
        if match(directed_4[i], SG, 4):
            motif_counts[i] += 1
Example #2
0
 def count_iso(self, G, sg, verbose=False):
 if verbose:
     print(sg)
 nodes = snap.TIntV()
 for NId in sg:
     nodes.Add(NId)
 # This call requires latest version of snap (4.1.0)
 SG = snap.GetSubGraphRenumber(G, nodes)
 for i in range(len(self.motifs)):
     if self.match(self.motifs[i], SG):
         self.counts[i] += 1
def count_iso(G, sg, verbose=False):
    # if verbose:
    #     print(sg)
    nodes = snap.TIntV()
    for NId in sg:
        nodes.Add(NId)
    # This call requires latest version of snap (4.1.0)
    SG = snap.GetSubGraphRenumber(G, nodes)
    for i in range(len(directed_3)):
        if match(directed_3[i], SG):
            motif_counts[i] += 1
Example #4
0
def count_iso(G, sg, motifs, verbose=False):
    """Given a set of 3 node id in sg, obtains the subgraph from the original graph.
    It then matches this graph with one of the 13 graphs in directed_3."""
    if verbose:
        print(sg)
    nodes = snap.TIntV()
    for NId in sg:
        nodes.Add(NId)
    # This call requires latest version of snap (4.1.0)
    SG = snap.GetSubGraphRenumber(G, nodes)
    for i in range(len(motifs)):
        if match_3(motifs[i], SG):
            motif_counts[i] += 1