2cdc4d3c1d17e1ac8be1c44ca54d772084c76f18,tutorials/basics/1_first.py,,build_karate_club_graph,#,49

Before Change


import dgl

def build_karate_club_graph():
    g = dgl.DGLGraph()
    // add 34 nodes into the graph; nodes are labeled from 0~33
    g.add_nodes(34)
    // all 78 edges as a list of tuples
    edge_list = [(1, 0), (2, 0), (2, 1), (3, 0), (3, 1), (3, 2),
        (4, 0), (5, 0), (6, 0), (6, 4), (6, 5), (7, 0), (7, 1),
        (7, 2), (7, 3), (8, 0), (8, 2), (9, 2), (10, 0), (10, 4),
        (10, 5), (11, 0), (12, 0), (12, 3), (13, 0), (13, 1), (13, 2),
        (13, 3), (16, 5), (16, 6), (17, 0), (17, 1), (19, 0), (19, 1),
        (21, 0), (21, 1), (25, 23), (25, 24), (27, 2), (27, 23),
        (27, 24), (28, 2), (29, 23), (29, 26), (30, 1), (30, 8),
        (31, 0), (31, 24), (31, 25), (31, 28), (32, 2), (32, 8),
        (32, 14), (32, 15), (32, 18), (32, 20), (32, 22), (32, 23),
        (32, 29), (32, 30), (32, 31), (33, 8), (33, 9), (33, 13),
        (33, 14), (33, 15), (33, 18), (33, 19), (33, 20), (33, 22),
        (33, 23), (33, 26), (33, 27), (33, 28), (33, 29), (33, 30),
        (33, 31), (33, 32)]
    // add edges two lists of nodes: src and dst
    src, dst = tuple(zip(*edge_list))
    g.add_edges(src, dst)
    // edges are directional in DGL; make them bi-directional
    g.add_edges(dst, src)

    return g

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Print out the number of nodes and edges in our newly constructed graph:

After Change


        31, 32])
    // Edges are directional in DGL; Make them bi-directional.
    u = np.concatenate([src, dst])
    v = np.concatenate([dst, src])
    // Construct a DGLGraph
    return dgl.DGLGraph((u, v))

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Print out the number of nodes and edges in our newly constructed graph:
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: dmlc/dgl
Commit Name: 2cdc4d3c1d17e1ac8be1c44ca54d772084c76f18
Time: 2020-03-21
Author: wmjlyjemaine@gmail.com
File Name: tutorials/basics/1_first.py
Class Name:
Method Name: build_karate_club_graph


Project Name: dmlc/dgl
Commit Name: e7679cf2e69ac48cc0c685ad2bf0d87b9cac913b
Time: 2018-10-12
Author: yg1246@nyu.edu
File Name: python/dgl/graph.py
Class Name: DGLGraph
Method Name: line_graph


Project Name: dmlc/dgl
Commit Name: 79f62400fe05cfe6145b748e2272174198761896
Time: 2018-09-21
Author: wmjlyjemaine@gmail.com
File Name: python/dgl/data/tree.py
Class Name: SST
Method Name: _build_tree