The ego command returns the neighbors of a focal node. Assume that I have a network of 100 nodes, then ego returns a list of 100 lists, with each nested list consisting of neighbors for the focal node. Since different nodes have different number of neighbors, I am unable to use data frame because data frame requires the length of elements to be the same. Then how can I export this list of lists to a text file, along with the name for each focal node?
I would like the output format to look like this:
A B C D …
Z F G H J…
The first node A (Z) is the focal node that I want to have neighbors for. The remaining nodes (B, C, D,…) are the neighbors for A, and F, G, H, J are the neighbors for Z.
Any help will be appreciated!