我有张桌子:
CREATE TABLE MENUPOINT (
id BIGINT NOT NULL,
parent BIGINT,
name VARCHAR(64),
CONSTRAINT "MENUPOINT_pkey" PRIMARY KEY(id),
CONSTRAINT fkc75dac36251dd346 FOREIGN KEY (parent)
REFERENCES MENUPOINT(id)
ON DELETE NO ACTION
ON UPDATE NO ACTION
NOT DEFERRABLE
);
以下
我被这个问题弄糊涂了。以下是我的方法:
Lets say the two nodes are node1 and node2
For any node (lets say node1), find the path from Root to
node1 and store it in an HashMap
For the other node node2, find the path from root to node2, and while traversing back,
check if any of the nodes are present in the
我有一个网格映射,我需要找到两个节点之间的最短路径,但是路径必须包括一些节点。
我已经考虑过尝试所有的排列,但是映射的大小和必须节点的数目都是可变的,所以我想使用最优的算法。
该地图将类似于以下内容:
-Dark brown square at Y18 is the start point
-Light brown squares from B20 to S20 are the end point (can make just one end point if needed)
-White squares are walls (you cannot go through them)
-Blue
我有一个场景,我需要计算第一个节点(:employee)之间的自定义度,当这个节点的标签是:natural或:relative时,它只应该增加到另一个节点,而不是当它是:legal时。
示例:
问题是,我在生成custom degree属性时遇到了困难,因为我需要它。
到目前为止,我试着玩FOREACH和CASE,但是没有运气。我最接近于获得某种计算出的定制程度的方法是:
match p = (:employee)-[*5..5]-()
WITH distinct nodes(p) AS nodes
FOREACH(i IN RANGE(0, size(nodes)) |
FOR
我有一个有向加权图,它的权重为正数,如下所示:
我想做的是:-
查找两个节点之间的所有可能路径。
根据路径长度(由边缘权重确定)按升序排列路径,至少前5位表示。
使用一种最优的方法来做到这一点,这样即使在节点数量更多的情况下,程序也不会花费太多的时间计算。
例如:-假设我的初始节点是d,最后一个节点是c。所以输出应该类似于
d to c = 11
d to e to c = 17
d to b to c = 25
d to b to a to c = 31
d to b to a to f to c = 38
我怎样才能做到这一点?