我是新來圖並試圖瞭解上下文關係如何映射到它們中。圖形,邊緣和上下文信息
我看實例系統介紹簡單的演示(1),例如:
# I want to organize the seating arrangement for my party
# Bob does not like John, so I can say
----------- ------------
| Bob | <--- excludes --- | John |
----------- ------------
但如果我想說的是,鮑勃竟然喜歡約翰,但不喜歡被他身邊的時候他由他的女朋友瑪麗陪同(你知道,他們總是親吻,你不能再跟他們說話)。我想過兩種解決方案:
# solution 1: create an intermediary node.
# now, the problem is that, if I want to know who John excludes,
# I have to look at the node John + every other node he might be the child of.
| John |
----------- ------------- -----------
| Bob | <--- excludes --- | Couple | <
----------- ------------- ------------
| Mary |
------------
# solution 2: target the edges, and make them cumulative
# here if I want to know who John excludes,
# I just have to target the node John and then check for
# additional logic (in this case, check if Mary is present too).
----------- ------------
| Bob | <--- excludes --- | John |
----------- ^ ------------
^ |
| |
excludes <---- requires (some logic here)
|
----------
| Mary |
----------
請注意,我沒有找到任何像這樣的例子,甚至不知道是否在圖形處理直接這類問題是正確的解決方案。任何想法?謝謝。
謝謝博丹!國家模式看起來很有希望。如果我理解的很好,那麼這個目標節點就是約翰的衛星。國家模式似乎解決了問題的一部分。例如:如果尋找約翰在瑪麗加入時排除的人,我會馬上得到鮑勃。然而,在尋找誰排斥鮑勃時,我可能必須通過許多不同的狀態遍歷許多對象。 – Raphael
對不起,我想過更多。這看起來很合理:你只需鏈接John和Bob,然後檢查是否符合排除條件。謝謝! – Raphael