Skip to content
Heterogeneous information network representation learning
Python C Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
ds Update ds/Network.pyFix (def a_random_walk(self, node, length)) Oct 30, 2018
model_c update Jun 9, 2018
.gitignore update Jun 9, 2018 (model/main) modify printf Dec 13, 2017


HIN2Vec learns distributed representations of nodes in heterogeneous information networks (HINs) by capturing the distiguishing metapath relationships between nodes. Please refer the paper here.


Compile the source code

cd model_c/src

How to use?


To run HIN2Vec on Zachary's karate club network, execute the following command from the repository home directory:

python res/karate_club_edges.txt node_vectors.txt metapath_vectors.txt -l 1000 -d 2 -w 2


See help for the other available options to use with HIN2Vec.

python --help

Input HIN format

The supported input format is an edgelist (separated by TAB):

node1_name node2_type node2_name node2_type edge_type

The input graph is assumed to be directed by default, which means that for an edge in a undirected graph, you need to add two directed edges. For example:

1 U 11 U U-U ... 11 U 1 U U-U ...


After learning, HIN2Vec outputs two files: node representations and metapath representations.

The node representation file has n+1 lines for a graph with n nodes with the following format.

num_of_nodes dim_of_representation
node_id dim1 dim2 ... dimd

where dim1, ... , dimd is the d-dimensional node representation learned by HIN2Vec.

The metapath representation file has k+1 lines for a graph with k targeted metapath relationships with the following format.

num_of_metapaths dim_of_representation
metapath1 dim1 dim2 ... dimd

where dim1, ... , dimd is the d-dimensional metapath representation learned by HIN2Vec. The number of target metapaths is related to the window size set for learning and the schema of the given graph.

Check the learned vectors

Members in the Zachary's karate club network natually seperate into two groups. To treat the group classification for members as a binary classification:

python tools/ node_vectors.txt res/karate_club_groups.txt


If you find HIN2Vec useful for your research, please cite the following paper:

    title={HIN2Vec: Explore Meta-paths in Heterogeneous Information Networks for Representation Learning},
    author={Fu, Tao-yang and Lee, Wang-Chien and Lei, Zhen},
    booktitle={Proceedings of the 2017 ACM on Conference on Information and Knowledge Management},


Please send any questions you might have about the code and/or the algorithm to or

You can’t perform that action at this time.