How to make DGL heterogeneous graph?

Hello everyone, I am new to deep learning and dgl.
I want to use dgl to make a graph for the commit history, using which I want to find whether a commit will be buggy or not.
For this, I want to make a heterogeneous graph that would have a structure like shown in the figure. But a commit with a unique commit id and properties, modifies files, with each edge having a specific weight called lines added and lines removed. Each commit has an author and parent commit.
I am able to create it in networkx. However, I am unable to get it into dgl heterogeneous graph. I am unable to map that structure to dgl heterogenous graph.
Any help would be greatly appreciated! Thank you!

Any tutorial or help material to shape my thinking would be appreciated. I think i am looking at the problem wrong, but don’t know how to look at it right too.

Here is the code sample of how I create the graph using networkx

def make_graph(df, limit=None):
    gitt = Git("repos/" + "cassandra")
    print(f"Total commits: {len(df)}")
    nx_g = nx.DiGraph()
    for i, row in df.iterrows():
        row["commit_id"] = i
        print(f"{i} -- {row['commit_id']}")

        commit = gitt.get_commit(row["commit_id"])

        # make the commit node
        commit_node_dict = {
            "author_date": commit.author_date,
            "sha": commit.hash,
            "la": commit.insertions,
            "ld": commit.deletions,
            "buggy": row["buggy"]
        }
        # datatime to epoch
        commit_node_dict["author_date"] = int(commit_node_dict["author_date"].timestamp())
        nx_g.add_node(row["commit_id"], label="commit", features = [commit_node_dict["author_date"], commit_node_dict["la"], commit_node_dict["ld"], commit_node_dict["buggy"]])

        # get the commit node
        commit_node = nx_g.nodes[row["commit_id"]]
        print(commit_node)
        # print(commit_node["features"])

        # make the file nodes
        for file in commit.modified_files:
            filename = file.filename

            try:
                nx_g.add_node(filename, label="file")
            except Exception as e:
                pass

            nx_g.add_edge(row["commit_id"], filename, features = file.added_lines + file.deleted_lines, label="modified")

        # make the person node

        author = commit.author

        try:
            nx_g.add_node(author.email, label="person")
        except Exception as e:
            pass

        nx_g.add_edge(row["commit_id"], author.email)

        # make parent links between commits

        for parent in commit.parents:
            try:
                nx_g.add_node(parent, label="commit", features = [0, 0, 0, 0])
            except Exception as e:
                pass
            nx_g.add_edge(row["commit_id"], parent, label="parent")


    return nx_g

you can refer to this guide about heterogeneous graph

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.