Open neenerrh opened 4 years ago
There might be two possible solutions: 1) You could convert edge list to adjacency list using networkx API (I recommend this one). 2) If you still want to load your edge list, did you specify the parameter "--graph-format edgelist" ? Please see https://github.com/houchengbin/OpenANE/blob/1395f3d0a2a26ec7690731fa910469ecef455465/src/main.py#L27, in which the default parameter is "adjlist".
If the solution 2 is still not working, could you please paste your edge list here? e.g., the first 10 lines of your edge list.
I did changed the graph-format to edgelist. Below is the edgelist 1 932 1 931 1 911 1 97 1 942 1 912 1 904 1 96 1 943 1 924
Please see my attempt below: 1) Put the above edgelist in a file under 'data' folder, namely 'graph.txt'; 2) Generate a file for attributes under 'data' folder, namely 'attr.txt';
1 0.1 0.2 0.3
932 0.1 0.2 0.3
931 0.1 0.2 0.3
911 0.1 0.2 0.3
97 0.1 0.2 0.3
942 0.1 0.2 0.3
912 0.1 0.2 0.3
904 0.1 0.2 0.3
96 0.1 0.2 0.3
943 0.1 0.2 0.3
924 0.1 0.2 0.3
Note that, if you run an Attributed Network Embedding (ANE) method, e.g., '-method abrw', you should also provide the corresponding attributes. Otherwise, you may get the error message as you provided above.
3) Having the above two files, try the following command:
cd OpenANE
python src/main.py --method abrw --ABRW-topk 5 --graph-format edgelist --graph-file data/graph.txt --attribute-file data/attr.txt --task lp --emb-file emb/test_abrw_emb --save-emb
Note that, you may need to set '--ABRW-topk 5', because the graph is too small. The number specified here should be larger than the number of nodes in the graph.
Thank you for the detailed code and explanation. I tried using it with the provided edge list and attribute list. I believe what caused the error is that I tried to add attributes to nodes that are not in my edgelist
I tried to run the ABRW method by creating the graph using edgelist. But I encountered an error when reading the attribute file
self.g_u.read_node_attr(attribute_file) File "\model\libnrl\graph.py", line 83, in read_node_attr self.G.nodes[vec[0]]['attr'] = np.array([float(x) for x in vec[1:]]) File "C:\Users\Administrator\Anaconda3\lib\site-packages\networkx\classes\reportviews.py", line 178, in __getitem__ return self._nodes[n] KeyError: '98'
But the code works fine when I used adjacency list to create the graph. Do you have any suggestion