简体   繁体   中英

Find most suitable nodes from a starting node, start and end nodes are indirectly connected and edges are weighted

in the image below is a subgraph of my whole graph shown. I have three different kind of nodes, green, blue and violet ones.

The green and violet ones are indirectly connected via the blue nodes.

Blue nodes are connected among each other with directed edges which are weighted. The blue edges are weighted but not the green or violet ones.

The problem I want to solve is the following: I would like to find the most suitable violet nodes to the green one. , eg I want be able to say that for green node GA the three most suitable violet nodes are V1 , V4 , V42 .

What makes a node suitable?

A perfect match would be when the green node connects to all blue nodes the violet one connects to. However, the green node could connect to more blue nodes. This would still be the best score for a violet node.

If green and violet do not connect to the same blue node but to blue nodes that are connected to each other the algorithm needs to take the weights of the edges between the blue nodes into account. This could not result in a perfect match but still a good match.

What makes it more or less suitable?

The more hops between blue nodes are needed to connect blue nodes the green and violet nodes are connected the smaller the score of the violet node is. Also if the weight between the blue nodes is the lesser the score of the violet node is, here the direction from green to violet is the one to consider.

If the green is not connected to some blue nodes, it would be a penalty and the score for the violet node would be smaller.

What graph algorithms can you think of to solve this problem?

I am planning to use the neo4j database.

我的子图

A perfect match would be when the green node connects to all blue nodes the violet one connects to.

I think that this means there is a path from a green node to a violet one that passes through just one blue node. If there is more than one violet node that is just one blue node away from a green node, then you want all such vilet nodes. Please confirm this.

If my guess about your requirement is correct, then the Dijsktra algoritm will give your answer. The algorithm will tell you how far away every violet node is from each green node - so you can filter out the ones that are exactly two hops away.

Do you have a sample dataset?

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