简体   繁体   中英

Is there a way to allow GraphSAGE take into account weighted edges

Currently, I am using a great python library, StellarGraph, to implement GraphSAGE (graph neural network) and for most uses, the library works very well.

I now have a situation where I have graphs with weighted edges - the weights reflect the relative importance of some relationships compared to others. In other words, some links between nodes have lower weights (low importance) and others have higher weights (high importance).

It would be very useful for clustering and perhaps even node classification in situations where weights are taken into account during graph network training.

Is there a way to have GraphSAGE / python StellarGraph take weighted edges into account?

This is now supported in StellarGraph in version 1.2.0 , via the weighted=True parameter to the data generators.

For example, for GraphSAGE's GraphSAGENodeGenerator :

G_generator = GraphSAGENodeGenerator(G, 50, [10,10], weighted=True)

For the details of what this means (quoting the pull request #1667 that fixed the relevant issue #462 ):

This expands GraphSAGE (undirected and directed) to support weighted sampling, where edges with higher weights are taken proportionally more often.

For example, suppose there's there's 4 edges from node A:

A -0- B, A -1- C, A -2- D, A -3- D

An unweighed walk starting at A will choose each of the edges with equal propability and so end up on B, C or D in proportion 1:1:2 (edge counts). A weighted walk will choose the edges proportional to the weights, so end up on the vertices in proportion 0:1:5 (sum of edge weight). (Worth specifically highlighting: a weighted walk will never chose the AB edge because it has weight 0.)

The full set of algorithms that support edge weights is marked via the "Edge weights" column in the table of demos in the documentation .

Did you find a workaround or solution to this? I had the same question as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM