Best Way to Store/Access a Directed Graph

后端 未结 6 618
清酒与你
清酒与你 2021-02-01 09:14

I have around 3500 flood control facilities that I would like to represent as a network to determine flow paths (essentially a directed graph). I\'m currently using SqlServer an

6条回答
  •  伪装坚强ぢ
    2021-02-01 09:33

    Yes (maybe). Your data set sounds relatively small, you could load the graph to memory as an adjacency matrix or adjacency list and query the graph directly - assuming you program.

    As far as on-disk format, DOT is fairly portable/popular among others. It also seems pretty common to store a list of edges in a flat file format like:

    vertex1 vertex2 {edge_label1}+
    

    Where the first line of the file contains the number of vertices in the graph, and every line after that describes edges. Whether the edges are directed or undirected is up to the implementor. If you want explicit directed edges, then describe them using directed edges like:

    vertex1 vertex2
    vertex2 vertex1
    

提交回复
热议问题