Graph
No preview image
Model was written in NetLogo 5.0.4
•
Viewed 479 times
•
Downloaded 22 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
breed [nodes node] directed-link-breed [edges edge] globals [ ; mouse-globals mouse-clicked? %mouse-down? %mouse-time ; edge-creation-globals first-node] to setup set %mouse-down? false end ; Mouse-Utility ; Set mouse-clicked to true when the mouse is released ; Use it within a "forever"-command to go-mouse ifelse mouse-down? [ set %mouse-down? true ] [ ifelse %mouse-down? = true [ set mouse-clicked? true ] [ set mouse-clicked? false ] set %mouse-down? false ] end ; Create nodes to node-creation go-mouse if mouse-clicked? = true [ let nh false ask patch (round mouse-xcor) (round mouse-ycor) [ ifelse any? nodes-here [ set nh true ] [ set nh false] ifelse nh [ask nodes-on patch (round mouse-xcor) (round mouse-ycor) [die] ] [sprout-nodes 1 [setxy mouse-xcor mouse-ycor set shape "dot" show who] ] ] ] end ; Create Edges to edge-creation go-mouse if mouse-clicked? = true [ ifelse not is-agent? first-node [ ; mark first node let nh false ask patch (round mouse-xcor) (round mouse-ycor) [ ifelse any? nodes-here [ set nh true ] [ set nh false] if nh [set first-node one-of nodes-here] ] ] [ ; mark second node let nh false ask patch (round mouse-xcor) (round mouse-ycor) [ ifelse any? nodes-here [ set nh true ] [ set nh false] if nh [ ask one-of nodes-here [ let edge-exists false ask first-node [set edge-exists out-link-neighbor? myself ] ifelse edge-exists [ask in-edge-from first-node [die] ] [create-edge-from first-node]] set first-node false ] ] ] ] end to make-input let input [] let kv-pair [] let neighs [] ask nodes [ set kv-pair [] set neighs [] set kv-pair fput who kv-pair ask out-edge-neighbors [set neighs fput who neighs] set kv-pair lput neighs kv-pair set input fput kv-pair input ] show input end
There is only one version of this model, created about 11 years ago by Martin Dobiasch.
Attached files
No files
This model does not have any ancestors.
This model does not have any descendants.