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 *****
> _____________________________________________________________________ SOCNET> 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
>
>
> 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