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.