You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
git clone https://github.com/skojaku/graphvec
cd graphvec
conda develop .
Dependency:
See setup.py
Usage
Following the scikit-learn's API design, all algorithms have two methods.fit and .transform. The .fit method takes a network to learn the network structure, and the .transform produces the emebdding of nodes. More specifically, follow the steps below.
First, load a graph embedding method. For demonstration, we use Node2Vec. See the "Available algorithms" Section for other graph embedding methods.
importgraphvecmodel=graphvec.Node2Vec()
Second, call .fit with the network A:
model.fit(A)
where A is the adjacency matrix in scipy.sparse format. For networkx user, networkx.Graph can be converted to the scipy.sparse format by A = nx.adjacency_matrix(G).
Lastly, call .transform to generate an embedding:
emb=model.transform(dim=64)
where dim is the number of dimensions. emb is a numpy.ndarray with size (number of nodes, dim). The ith row in emb (emb[i, :]) is the embedding vector of the ith node in the given adjacency matrix.