# ego graph shell layout with less than 2 dimensions

39 views

### Matthew Kline

Aug 2, 2022, 2:35:26 PM8/2/22
to networkx-discuss
Hello!
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?

Thanks!

-Matt

### Dan Schult

Aug 2, 2022, 3:57:28 PM8/2/22
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)])
```

### Matthew Kline

Aug 11, 2022, 9:56:54 AM8/11/22
to networkx-discuss
I appreciate your answer.  I apologize for the delayed response I have been.

I currently have an ego graph with a shell layout using the code:

G_sub= nx.ego_graph(G,(item),radius=1, center= True, undirected=True, distance='weight')

# create list for nlist. This positions (item) in center of subgraph
others = list(G_sub)
others.remove(item)

# Specify shell positioning of nodes. "Items" is centered, "others"/connected nodes will surround

pos = nx.shell_layout(G_sub, nlist=[(item,), others],dim=2)
for n, p in pos.items():
G_sub.nodes[n]['pos'] = p

In this case, "Item" Is the center node and "others" are the connected nodes which creates the network I have attached.

How would I go about translating this to a wheel or star graph?

Thanks so much for all of your help!!
network.PNG