如何从 Excel 中的数据中查找边

how to find edge from data in Excel

我正在尝试使用 Excel 和 VBA 查找节点之间的关系(边)。我将使用 Gephi 中的输出,但是我在 Excel 中的数据太大了,这是我的问题的一个例子,以找到真正的关系。

如果我有这个数据:

  'data for id_books that user_id borrowed
    user_id        id_book     book
    1                55        physic           
    2                55        physic
    2                55        physic
    3                55        physic
    4                55        physic

这是输出,告诉我从图书馆借了同一本书的用户:

    nodes(user_id):       edges(relation between user_id)
                           source,target
      1                    1,2
      2                    1,3
      3                    1,4 
      4                    2,3
                           2,4
                           2,3
                           2,4

只显示一次 1,2 是否正确?

离散数学中有两个密切相关的结构,图和多重图。 graph is a set of nodes and a set of pairs of nodes. If you want to define a graph whose nodes are users and whose edges correspond to the relation of having borrowed the same book at least once, then it wouldn't make sense to list an edge like (1,2) more than once. On the other hand, in a multigraph edges can be repeated. Storing (1,2) multiple times would tell you that user 1 and user 2 have borrowed the same book, with at least one of those users having borrowed the book at least twice. If you would find that information useful, use a multigraph. Otherwise use a graph. I would think that something like Gephi 可以绘制图形和多重图形,所以从这个意义上说,它真的取决于你。但是请注意,多图的绘图可能更难阅读,因为它们在视觉上更加混乱。我讨厌混乱的图表,所以我可能更喜欢使用单边图而不是多边多图,但这更符合我的偏好。您可能有充分的理由在预期的应用程序中更喜欢多重图。