> Suppose I want to calculate the similarities between the nodes with ids
> {100,60,50,90}, if I set similarity.invlogweighted(graph,
> vids=c(100,60,50,90)). Then the fist row is for the node with id 100?
Yes.> I am trying to do it in the following way, do you think I am in a right > way? > (1) Firstly, give each node a number(from 0 to n-1) which is used as the > id of the nodes, and record the ids for the m nodes. You don't need that, igraph automatically assigns a numeric identifier to each node in the [0; n-1] range. > (2) After I get a m*n matrix from similarity.invlogweighted(), I get the > columns corresponding to the m nodes. Yes. > So another question is that, if I input the graph with the function > read.graph(file="graph_ids.txt",format="edge list"), will the numbers be > used as the ids, or new ids will be assigned according to the > sequence of the nodes? For example, if the first edge is "0, 100", will > the node "100" be assigned an id "1"? format="edgelist" uses the numeric IDs that you have in the file. The result is that if your IDs are not consecutive, you will have isolated nodes in the graph because igraph requires IDs to be consecutive in the [0; n-1] range. So, for instance, this edgelist file will give you a triangle: 0 1 1 2 0 2 But this edgelist file would give you a triangle plus 1000 isolated nodes because IDs from 0 to 999 (inclusive) were not used: 1000 1001 1001 1002 1000 1002 So, if your node IDs are consecutive from 0 to n-1, use format="edgelist". If your node IDs are not consecutive or you use non-numeric node IDs, then use format="ncol", which would assign IDs to the nodes from the range [0; n-1] and record the *original* identifiers from your file in the "name" vertex attribute (accessible via V(g)$name). > BTW, would you please tell me where can I find the source code about > similarity.invlogweighted()? It is written in C and you can find it here: https://github.com/igraph/igraph/blob/master/src/cocitation.c#L159 -- T. _______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
