[英]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 . ,例如,我想说对于绿色节点GA ,三个最合适的紫色节点是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.我打算使用 neo4j 数据库。
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.如果我对您的要求的猜测是正确的,那么 Dijsktra 算法将给出您的答案。 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?你有样本数据集吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.