My network has 100 nodes and 196 edges. Each node has an attribute of "smoker" or "non-smoker". There are 5 smokers and 95 non-smokers.

I want to know the probability of being a smoker given that you are connected to a smoker.

16 nodes in the network are connected to a smoker.

2 nodes are connected to a smoker AND are a smoker themselves.

I want to set up a conditional probability P(A|B) where:

A = node is a smoker

B = node has a neighbor who is a smoker

P(A) = 5/100

P(B) = 16/100

P(A∧B) = 2/100

So P(A|B) = .02/.16 = .125

Is this the right way to do this? I'm a little uncertain about using the number of nodes as the denominator for my probabilities. Might edges make sense too? Particularly for P(B)--the sum of degrees of smoker nodes divided by total edges. In this case 18/196.

Also, if I loop through the network and look at all neighbors, there are 392 (196*2). My graph is not directed, but might this number be relevant too. Thinking of each neighbor-neighbor relationship as a ball in a bowl. In the context of probability, is source->target identical to target->source if the graph is not directed? Or should I be considering each neighbor for each node's perspective?

Visualization below: Blue nodes are smokers

enter image description here

  • 1
    $\begingroup$ If you want to increase the likelihood of someone answering your question, please include pictures. $\endgroup$
    – mhdadk
    Jun 23, 2021 at 14:40
  • $\begingroup$ @mhdadk okay I added a visualization of the graph. I'm not sure if I have any pictures that help articulate the question though $\endgroup$ Jun 23, 2021 at 14:49
  • $\begingroup$ While the plot of the graph is refreshing to see on stat.SE, you could probably just summarize the required information for this problem in a contingency table. $\endgroup$
    – Galen
    Jun 23, 2021 at 15:06

1 Answer 1


Find the people who are connected to smokers.

Of those people, how many are smokers?


The fact that there is a graph could lead one to believe that fancy graph analysis is necessary, and you could do something with how many connections one has to smokers or second-degree connections (connected to no smokers, but connected to a non-smoker who has a smoker connection), but I do believe it is this simple to solve the stated problem.

  • $\begingroup$ (+1) The fact that there is a graph could lead one to believe that fancy graph analysis is necessary. It can be tempting to use sophisticated representations such as graphs, hypergraphs, and simplicial complexes, but sometimes you just need a probability measure on sets. $\endgroup$
    – Galen
    Jun 23, 2021 at 15:03
  • $\begingroup$ Thank you for your answer and comment. I think that I'm guilty of this. The graph I'm actually working on is more complicated than this but it's helpful to think of the nodes as belonging to a set. I can even be explicit about it and add a yes/no 'connected_to_smoker' attribute, group like nodes together as sets and then find the intersection of the 'smoker' set and the 'is_connected_to_smoker' set. Thanks again. $\endgroup$ Jun 23, 2021 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.