Print

Print


***** To join INSNA, visit http://www.insna.org *****
Hello all, 

First, thank you Moses for your advice. I have been trying in R statnet to mimic  what you did in python. I am running into problem however, and hope someone can help. 

From what I can tell, the ego networks generated with ego.extract() is not stored as a separate matrix, but appears to be an object that is still associated with my original network. I want to convert it to a unique matrix so that I can remove the focal node and merge it with other ego networks as Moses described. 

Her is an example to illustrate what I mean. 

The following code:

ego224 = ego.extract(mx, ego=224, neighborhood = "combined")
ego224net = as.matrix(ego224)

gives me this:

> ego224net
      [,1]        
   AA Integer,7396

Does anyone know how I can convert the ego network generated by ego.network() to a format that I can then delete nodes from and merge with other networks?

Again, my overall goal is to create an "ego" network from two focal nodes, to exclude those nodes in the "two-ego" network, and then calculate density, centerlization, and other measures on the "two-ego" network. So if you know another way to do this, feel free to tell me I am on the wrong path and set me straight. 

More details of my ultimate goal: 

Would anyone know how to extract an ego-neighborhood for two nodes in the SNA R package?

I know that ego.extract will allow me to extract ego neighborhoods for specific nodes, but I want to extract the combined neighborhood for two nodes (that is all nodes connected to nodes 3 or 4, for example). 

I then need to calculate size, density, and centralization on each extracted ego neighborhood. For these measures,  I need to exclude the focal nodes. Can I exclude the focal nodes from the resulting ego network when using ego.extract?



On Sat, Feb 22, 2014 at 3:59 AM, Moses Boudourides <[log in to unmask]> wrote:
Jesse, I'm afraid I don't know how to do this in the SNA R package
(since I'm not using R that often) but I can show you how it is done
using Python's NetworkX - I guess you just need to apply similar
functions in SNA:

First, how to extract the 2--ego network:

>>> G = nx.barabasi_albert_graph(20,3)
>>> G.nodes()
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
>>> G.edges()
[(0, 3), (0, 4), (0, 5), (0, 6), (0, 8), (0, 12), (1, 11), (1, 9), (1,
3), (1, 7), (2, 3), (2, 4), (2, 6), (2, 9), (2, 13), (2, 18), (3, 4),
(3, 5), (3, 6), (3, 7), (3, 8), (3, 9), (3, 11), (3, 12), (3, 14), (3,
16), (4, 5), (4, 7), (4, 11), (4, 12), (5, 10), (6, 8), (6, 10), (7,
10), (7, 14), (7, 15), (7, 16), (7, 17), (9, 13), (9, 15), (9, 17),
(9, 19), (11, 14), (11, 15), (11, 16), (11, 17), (11, 18), (12, 13),
(15, 19), (15, 18), (16, 19)]
>>> n3 = G.neighbors(3)
>>> n3
[0, 1, 2, 4, 5, 6, 7, 8, 9, 11, 12, 14, 16]
>>> n4 = G.neighbors(4)
>>> n4
[0, 2, 3, 5, 7, 11, 12]
>>> sn34 = set(n3).intersection(set(n4))
>>> n34 = list(sn34)
>>> n34
[0, 2, 5, 7, 11, 12]
>>> n34.extend([3,4])
>>> n34
[0, 2, 5, 7, 11, 12, 3, 4]
>>> H = G.subgraph(n34)
>>> H.nodes()
[0, 2, 3, 4, 5, 7, 11, 12]
>>> H.edges()
[(0, 12), (0, 3), (0, 4), (0, 5), (2, 3), (2, 4), (3, 4), (3, 5), (3,
7), (3, 11), (3, 12), (4, 5), (4, 7), (4, 11), (4, 12)]
>>> nx.density(H)
0.5357142857142857

Next, how to find the corresponding 2-alter-alter network:

>>> H.remove_nodes_from([3,4])
>>> H.nodes()
[0, 2, 5, 7, 11, 12]
>>> H.edges()
[(0, 12), (0, 5)]
>>> nx.density(H)
0.13333333333333333

Best,

--Moses

On Sat, Feb 22, 2014 at 1:15 AM, Jesse Sayles <[log in to unmask]> wrote:
> ***** To join INSNA, visit http://www.insna.org *****
> Hi Socnet users,
>
> Would anyone know how to extract an ego-neighborhood for two nodes in the
> SNA R package?
>
> I know that ego.extract will allow me to extract ego neighborhoods for
> specific nodes, but I want to extract the combined neighborhood for two
> nodes (that is all nodes connected to nodes 3 or 4, for example).
>
> I then need to calculate size, density, and centralization on each extracted
> ego neighborhood. For these measures,  I need to exclude the focal nodes.
> Can I exclude the focal nodes from the resulting ego network when using
> ego.extract?
>
> Thank you
> Jesse
>
> --
>
> Jesse Sayles
> PhD candidate
> School of Geographical Sciences & Urban Planning
> Arizona State University
> geoplan.asu.edu/sayles
>
>
>
> Graduate Assistant Fellow
> Rob and Melani Walton Sustainability Solutions Initiatives
> sustainabilitysolutions.asu.edu/programs/fellowships/?pid=7689
>
>
> _____________________________________________________________________ SOCNET
> is a service of INSNA, the professional association for social network
> researchers (http://www.insna.org). To unsubscribe, send an email message to
> [log in to unmask] containing the line UNSUBSCRIBE SOCNET in the body of
> the message.



--

Jesse Sayles
PhD candidate 
School of Geographical Sciences & Urban Planning
Arizona State University
geoplan.asu.edu/sayles

 

Graduate Assistant Fellow 

Rob and Melani Walton Sustainability Solutions Initiatives
sustainabilitysolutions.asu.edu/programs/fellowships/?pid=7689

_____________________________________________________________________ SOCNET is a service of INSNA, the professional association for social network researchers (http://www.insna.org). To unsubscribe, send an email message to [log in to unmask] containing the line UNSUBSCRIBE SOCNET in the body of the message.