Q:

Netlogo: Creating links to new neighbors

I try to generate a directed graph in Netlogo. There should only be one link between two nodes. I use the following code fragment:

breed [nodes node]
directed-link-breed [edges edge]

.
.
.

ask nodes
 [
    create-edges-to ((other nodes) with [not edge-neighbor? self])
 ]

It keeps creating two links (from and to) between the nodes. What's my error?
Thanks in advance!
Eric.

A:

There are two problems: first, using self in the context you are using it in checks if a node is connected to itself. You want myself here.
Second, because you are using directed links, if A is connected to B, B is considered a link neighbor of A, but not vice versa (because it's directed.) Think of link-neighbor as, "is there a way to get from turtle A to turtle B".
NetLogo offers in-link-neighbor? and out-link-neighbor? to address this. So you can do: 
ask nodes [
    create-edges-to other turtles with [not out-edge-neighbor? myself]
]

Keep in mind that because this is run for each individual turtle, you will have a linear degree distribution. If that's what you're intending, then great! But it might not be. (edit: actually thinking this through, there's no way you wouldn't if you want all turtles to be connected by one directed link, so never mind.) 

