Q:

Creating edge list from Netlogo social network

I am very new to Netlogo and have been using it to do basic network analysis. I have created a social network made up of 5 different turtle breeds. In order to continue my analysis in another program, I need to create an edge list( a two column list of all the connected nodes in the network). So the first column would have the breed and who number (ex. Actor 1) and the second column would list one of Actor 1's contacts 
(ex [Actor1, Actor2] [Actor 1, Director5] [Actor1, Producer 1]..........)
The output needs to be a txt or csv file so that I can import it easily into EXCEL.
I've tried:
   to make-edgelist
    file-open "Test.txt"
     ask links [file-show both-ends]
       ask turtles[file-show who]
    file-close
end

The problem is that 'both-ends' only reports the who number, not the breed. I can get the breed by using ask turtles [file-show who] but this appends the identifcation to the end of the edgelist which means a lot of manipulation to get things in the correct format. Does anyone have any suggetsions about how to build the edge list with the breeds+who numbers? I feel like I'm probably missing something simple, but I am new to Netlogo. Thanks!

A:

I'm assuming that whatever program you're using for your analysis can organize and rearrange your pairs as needed, so as long as all pairs are recorded your network should build fine regardless of order. Your approach using ask-links and both-ends is a good one, and works with a bit of tweaking (mainly just using the breed primitive to have the turtles include their breed in the output. Here's one example:
to pairs-out

  file-open "test.csv"
  file-type (word "End_1, " "End_2,\n" )
  ask links [
    ask both-ends [
      file-type (word breed " " who ",")
    ]
    file-type "\n"
  ]
  file-close

end

