Group Abstract Group Abstract

Message Boards Message Boards

0
|
7.4K Views
|
2 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Remove a fraction p of nodes (or edges) from a graph randomly?

Suppose we have the network (G) below : If we knock off each vertex with probability p (e.g p=0.5).What fraction of G survive the attack? now if we knock off each edge with probability p.What fraction of (G) survive the attack?

G=enter image description here

Ref: Réka Albert, Hawoong Jeong & Albert-László Barabási http://www.nature.com/nature/journal/v406/n6794/full/406378a0.html

POSTED BY: Amin C
2 Replies

Sure thing. Many thanks.

POSTED BY: Amin C

In the future, when you post both on Wolfram Community and on Mathematica.SE, please cross-reference the two posts. This is to avoid duplication of effort if the question is already answered in one place. Just include a link to the other one in both posts.

Link to M.SE version:


Response on the linked post:


To randomly remove a fraction $p$ of vertices or edges from a graph g, you can do the following:

p = 0.1; (* make sure p has a value *)

verticesToRemove = RandomSample[VertexList[g], Round[p VertexCount[g]]]

result = VertexDelete[g, verticesToRemove]

For edges:

edgesToRemove = RandomSample[EdgeList[g], Round[p EdgeCount[g]]]

result = EdgeDelete[g, edgesToRemove]

Is the result still connected? Check it with ConnectedGraphQ.

If the result graph is not connected, you can look at what is the size of the largest component in the result, relative to the total graph size:

Length@First@ConnectedComponents[result]/VertexCount[result]

Try it on a scale free network created using preferential attachment:

g = RandomGraph[BarabasiAlbertGraphDistribution[300, 2]]

Repeat the calculation 100 times and compute the average fraction of the largest component:

Table[
 verticesToRemove = RandomSample[VertexList[g], Round[p VertexCount[g]]];
 result = VertexDelete[g, verticesToRemove];
 Length@First@ConnectedComponents[result]/VertexCount[result],
 {100}
]

N@Mean[%]
POSTED BY: Szabolcs Horvát
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard