ego graph shell layout with less than 2 dimensions

Skip to first unread message

Matthew Kline

Aug 2, 2022, 2:35:26 PM (6 days ago) Aug 2
to networkx-discuss
I have been working on a project where I am analyzing ego graph networks in a shell layout. I need to use to format of the shell layout but through this dimensions cannot be less than 2.  This means that the network will show immediate and secondary connections.  Does anyone know how to bypass this requirement so that only primary connections are shown? 



Dan Schult

Aug 2, 2022, 3:57:28 PM (6 days ago) Aug 2
The nx.ego_graph() function returns the subgraph of the node of interest and its neighbors. If I understand you correctly you would like to remove the edges between the neighbors and just show the "star" shape of the primary node and the edges to its neighbors.  The easiest way would likely be to just construct a star_graph using the primary node and it's neghbors.

G = nx.wheel_graph(5)  # start from full graph
node = 0
H = nx.star_graph([node] + list(G[node]))
H.edges   # shows:  EdgeView([(0, 1), (0, 2), (0, 3), (0, 4)])

node = 1
H = nx.star_graph([node] + list(G[node]))
H.edges   # shows:  EdgeView([(1, 0), (1, 2), (1, 4)])
Reply all
Reply to author
0 new messages