Weighted Edges

74 views
Skip to first unread message

Shannon Tee

unread,
Feb 18, 2020, 6:29:23 PM2/18/20
to SNAP Users Group
I'm trying to use snap.py for the first time and looked through the documentation, but couldn't find any information of how to created weighted edges. Could anyone help me out or point me the documentation that has it? Also, does the node centrality (GetDegreeCentr, GetBetweenessCentr, GetEigenVectorCentr) take into account the edge weights?

Rok Sosic

unread,
Feb 19, 2020, 9:08:15 PM2/19/20
to snap-d...@googlegroups.com
Hi,

Yes, SNAP implements a number of node centrality algorithms with edge weights. They are available in Python, although they are not yet documented. Use TNEANet to define the graph structure and a vector of floats TFltV to provide weights. Available methods are GetWeightedBetweennessCentr, GetWeightedClosenessCentr, GetWeightedFarnessCentr, GetWeightedPageRank, GetWeightedShortestPath, GetWeightOutEdges. Documentation is available for the C++ version: http://snap.stanford.edu/snap/doc/snapuser-ref/index.html

Thanks,
Rok


On 02/18/20 15:29, 'Shannon Tee' via SNAP Users Group wrote:
I'm trying to use snap.py for the first time and looked through the documentation, but couldn't find any information of how to created weighted edges. Could anyone help me out or point me the documentation that has it? Also, does the node centrality (GetDegreeCentr, GetBetweenessCentr, GetEigenVectorCentr) take into account the edge weights?
--
You received this message because you are subscribed to the Google Groups "SNAP Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to snap-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/snap-discuss/123f2568-db57-44ba-a4d5-4aa907d4bd8f%40googlegroups.com.

Shannon Tee

unread,
Feb 19, 2020, 9:19:57 PM2/19/20
to SNAP Users Group
Good to know! Also, have you ever used snap with spark/pyspark before? I was trying to create the graph in a distributed setting if possible. Alternatively, i've seen that I could load the data to create a graph, right?


On Wednesday, February 19, 2020 at 6:08:15 PM UTC-8, Rok Sosic wrote:
Hi,

Yes, SNAP implements a number of node centrality algorithms with edge weights. They are available in Python, although they are not yet documented. Use TNEANet to define the graph structure and a vector of floats TFltV to provide weights. Available methods are GetWeightedBetweennessCentr, GetWeightedClosenessCentr, GetWeightedFarnessCentr, GetWeightedPageRank, GetWeightedShortestPath, GetWeightOutEdges. Documentation is available for the C++ version: http://snap.stanford.edu/snap/doc/snapuser-ref/index.html

Thanks,
Rok

On 02/18/20 15:29, 'Shannon Tee' via SNAP Users Group wrote:
I'm trying to use snap.py for the first time and looked through the documentation, but couldn't find any information of how to created weighted edges. Could anyone help me out or point me the documentation that has it? Also, does the node centrality (GetDegreeCentr, GetBetweenessCentr, GetEigenVectorCentr) take into account the edge weights?
--
You received this message because you are subscribed to the Google Groups "SNAP Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to snap-d...@googlegroups.com.

Rok Sosic

unread,
Feb 22, 2020, 6:05:03 PM2/22/20
to snap-d...@googlegroups.com

Hi,

SNAP works with large-memory machines where the entire graph is loaded in the main memory of one machine. A distributed setting will incur a significant time penalty, so we use it only for data pre-processing, but not for network analytics.

Best,

Rok

To unsubscribe from this group and stop receiving emails from it, send an email to snap-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/snap-discuss/558114ad-df79-4ee0-a0ad-f5bdac6492ca%40googlegroups.com.

SH Ho

unread,
Feb 22, 2020, 6:39:25 PM2/22/20
to snap-d...@googlegroups.com
Hi Rok

Thank you for your input.  Out of curiosity, what do you use for network analysis if you don't use SNAP?  And what are the evaluation criteria?  I guess if the graph is too big to fit in RAM then SNAP might not be the best tool?  But don't most other package would suffer from the same limitations too?

Thank you for your advice!
SH

Sent from BlueMail

Rok Sosic

unread,
Feb 24, 2020, 10:18:18 PM2/24/20
to snap-d...@googlegroups.com
Hi,

We can process networks with 100s of billions of edges on our machines. For larger networks, check out Spark-based solutions.

Best,
Rok

Qiao Zhang

unread,
Feb 2, 2022, 9:54:10 PMFeb 2
to SNAP Users Group
Hi Rok,

Hope you are doing well. I was looking into the snap.py and had the same question as of Shannon's. I tried creating a TNEANet and added attribution of weight to the edges as you instructed above, however, it didn't work for me. I couldn't find any sample code or instruction online, thus am wondering if you could kindly point out where I did wrong?


N = snap.TNEANet.New()
N.AddNode(1)
N.AddNode(5)
N.AddNode(8)
N.AddNode(9)

N.AddEdge(1,5)
N.AddEdge(1,8)
N.AddEdge(8,9)

N.AddFltAttrE('wei')

N.AddFltAttrDatE(0, 1.0, 'wei')
N.AddFltAttrDatE(1, 2.0, 'wei')
N.AddFltAttrDatE(2, 3.0, 'wei')

N.GetAttrIndE('wei')
PRankN = N.GetWeightedPageRank()

The error I am getting is - AttributeError: 'PNEANet' object has no attribute 'GetWeightedPageRank'.

Looking forward to your response.

Thank you!

Best,
Qiao

Rok Sosic

unread,
Feb 3, 2022, 7:51:24 PMFeb 3
to snap-d...@googlegroups.com

Hi Qiao,

GetWeightedPageRank() is a function, not a class method. Please call it with: snap.GetWeightedPageRank(N, ...).

The parameters are described here: http://snap.stanford.edu/snap/doc/snapuser-ref/d3/d73/namespaceTSnap.html#a1645fe3468627d68ff93c22d2f6a9f02

Best,

Rok

Qiao Zhang

unread,
Feb 14, 2022, 6:48:33 PMFeb 14
to SNAP Users Group
Thank you Rok! It works!
Reply all
Reply to author
Forward
0 new messages