How to verify if a graph obeys a power law?

[亡魂溺海] 提交于 2019-12-13 04:46:55

问题


I am using the GraphStream to generate syntethic graphs. What is the formula to verify if the graph obeys the power law? (I have only the number of nodes and edges) Thanks.


回答1:


So we have a graph with an edge collection named relations. We can gather the required data using a full table scan on this edge collection using AQL in ArangoDB. We need to unify _from and _to so we can count them. We use the collect statement to evaluate the diameter for each vertex:

FOR oneEdge IN relations 
  FOR edgeLink IN [ oneEdge._from, oneEdge._to ]
    COLLECT edgesCounterItem = edgeLink WITH COUNT INTO graphDiameter
      RETURN { what: edgesCounterItem, count: graphDiameter }

Now that we know the diameters, we need to group once more by the diameters:

FOR oneEdge IN relations 
  FOR edgeLink IN [ oneEdge._from, oneEdge._to ]
    COLLECT edgesCounterItem = edgeLink WITH COUNT INTO graphDiameter
      COLLECT powerCounts = graphDiameter WITH COUNT INTO powerCounter
        RETURN {numberEdges: powerCounts, vertexCount: powerCounter}

Now we want this nicely sorted so we can easily plot it:

FOR oneEdge IN relations 
  FOR edgeLink IN [ oneEdge._from, oneEdge._to ]
    COLLECT edgesCounterItem = edgeLink WITH COUNT INTO graphDiameter
      COLLECT powerCounts = graphDiameter WITH COUNT INTO powerCounter
        SORT powerCounts
          RETURN {numberEdges: powerCounts, vertexCount: powerCounter}

With this chart you then will be able to determine whether a power law is fullfilled or not.

Note: this definitely will require a lot of system resources to compute.



来源:https://stackoverflow.com/questions/33872730/how-to-verify-if-a-graph-obeys-a-power-law

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!