List Info

Thread: Re: Specifying the position for a node




Re: Specifying the position for a node
country flaguser name
United States
2008-03-06 14:48:40

Sandhya,

This is the complete code I used to test the fragment I posted. It runs fine for me.

globals [
    node-coordinates
]

breed [
    nodes node
]

to setup
    clear-all
  ;  setup-globals
    setup-nodes
end

to setup-globals
    set node-coordinates [
       ; [ 14.42 ;    7.12]
        [ -4.47 ;   -5.67]
        [  7.88   ; 12.29]
        [  2.80   ; -1.07]
        [-12.36     1.88]
        [ 16.31 ;   -6.01]
        [-12.91     9.70]
        [  2.36   ; 14.62]
        [  1.07   ; -6.46]
        [-13.92     1.99] ;      
    ]
end

to setup-nodes
    create-nodes (length node-coordinates) [
       ; let coordinate-pair (first node-coordinates)
        set node-coordinates (but-first node-coordinates)
        setxy (first coordinate-pair) (last coordinate-pair)
    ]
end
What sort of errors are you seeing?

Regards,

Nick


--- In netlogo-usersyahoogroup s.com, "arunachalamsandhya" <arunachalamsandhya...> wrote:
>;
> Hi Nick
>
> Is there any information missing in the hint that you gave me . I am
> getting a lot of errors or may be I am making some mistake .
>
> Thanks
>
> Sandhya
&gt;
> --- In netlogo-usersyahoogroups.com, "arunachalamsandhya"
> arunachalamsandhya wrote:
>; >
> > Hi Nick
> >
> > Thanks for the help . This is a great group.
>; >
> > Sandhya
&gt; >
> > --- In netlogo-usersyahoogroups.com, "Nick" <nickbenn> wrote:
>; > >
> > >
> > > Sandhya,
&gt; > >
> > > That's very straightforward to do, particularly if you have the
> > desired
&gt; > > X and Y coordinates for your nodes in a list (or a list of lists).
&gt; > >
> > > For example, assume that you have a global variable called
>; > > all-nodes-coordinates, and that its value is a list of XY
> coordinate
> > > pairs (with each coordinate pair specified as a list), e.g.:
> > > set all-nodes-coordinates [
> > > [ 14.42 7.12]
> > > [ -4.47 -5.67]
>; > > [ 7.88 12.29]
>; > > [ 2.80 -1.07]
>; > > [-12.36 1.88]
> > > [ 16.31 -6.01]
>; > > [-12.91 9.70]
> > > [ 2.36 14.62]
>; > > [ 1.07 -6.46]
>; > > [-13.92 1.99]
> > > ]
> > > (You could also use file-read to read a list of coordinate pairs
> > like
> > > this from a file; that's almost certainly a better approach than
> the
> > > literal assignment above, especially for 100 no des.)
> > >
> > > Also, let's assume there's a breed called nodes. The following
> > statement
> > > would then use all-nodes-coordinates to create one node for each
> > > coordinate pair, and place that node on the specified XY
> > coordinates:
> > > create-nodes (length all-nodes-coordinates) [
> > > let coordinate-pair (first all-nodes-coordinates)
> > > set all-nodes-coordinates (but-first all-nodes-coordinates)
> > > setxy (first coordinate-pair) (last coordinate-pair)
> > > ]
> > > Note that this statement uses the number of elements in
> > > all-nodes-coordinates to determine the number of nodes required,
> and
> > > creates those nodes. Each of those newly created nodes, in turn,
> > takes
> > > the first pair of coordinates from al l-nodes-coordinates (popping
> > that
> > > pair from the list, so that the next node to do this will work on
> > the
> > > next pair of coordinates), and use the two values in the pair as
> > its X
> > > and Y position.
> > >
> > > I hope this helps!
>; > >
> > > Regards,
&gt; > >
> > > Nick Bennett
&gt; > >
> > >
> > > --- In netlogo-usersyahoogroups.com, "arunachalamsandhya"
> > > <arunachalamsandhya> wrote:
>; > > >
> > > > Hi
> > > >
> > > > I have created the nodes and links and have turtles walking
> > between
&gt; > > > them, but the nodes are positioned randomly . I want to specify
> > where
> > > > the node(i.e x and y co-ordinates for say 100 node s) should
> > be ,please
&gt; > > > help me .
> > > >
> > > > Thanks
>; > > >
> > > > Sandhya
&gt; > > >
> > >
> >
>

__._,_.___
.

__,_._,___
Re: Specifying the position for a node
country flaguser name
United States
2008-03-07 11:44:36

Hi Nick

I was getting errors in the "set all-node-coordinates " saying it
expects two inputs . I tried assigning only one coordinate too to see
what was happeneing , but it is still with the same problem . I shall
try the new code fragment to see what was wrong . Thanks.

Sandhya

--- In netlogo-users%40yahoogroups.com">netlogo-usersyahoogroups.com, "Nick" <nickbenn...> wrote:
&gt;
> Sandhya,
>
> This is the complete code I used to test the fragment I posted. It
runs
> fine for me.
> globals [
> node-coordinates
&gt; ]
>
> breed [
> nodes node
>; ]
>
> to setup
&gt; clear-all
> setup-globals
> setup-nodes
> end
>
> to setup-globals
> set node-coordinates [
> [ 14.42 7.12]
&gt; [ -4.47 -5.67]
&gt; [ 7.88 12.29]
&gt; [ 2.80 -1.07]
&gt; [-12.36 1.88]
&gt; [ 16.31 -6.01]
&gt; [-12.91 9.70]
&gt; [ 2.36 14.62]
&gt; [ 1.07 -6.46]
&gt; [-13.92 1.99]
&gt; ]
> end
>
> to setup-nodes
> create-nodes (length node-coordinates) [
> let coordinate-pair (first node-coordinates)
&gt; set node-coordinates (but-first node-coordinates)
&gt; setxy (first coordinate-pair) (last coordinate-pair)
&gt; ]
> end
> What sort of errors are you seeing?
>
> Regards,
>
> Nick
>;
>
> --- In netlogo-users%40yahoogroups.com">netlogo-usersyahoogroups.com, "arunachalamsandhya"
> <arunachalamsandhya> wrote:
&gt; >
>; > Hi Nick
>; >
>; > Is there any information missing in the hint that you gave me . I
am
&gt; > getting a lot of errors or may be I am making some mistake .
> >
>; > Thanks
&gt; >
>; > Sandhya
> >
>; > --- In netlogo-users%40yahoogroups.com">netlogo-usersyahoogroups.com, "arunachalamsandhya"
> > arunachalamsandhya wrote:
&gt; > >
>; > > Hi Nick
>; > >
>; > > Thanks for the help . This is a great group.
&gt; > >
>; > > Sandhya
> > >
>; > > --- In netlogo-users%40yahoogroups.com">netlogo-usersyahoogroups.com, "Nick" <nickbenn> wrote:
&gt; > > >
>; > > >
>; > > > Sandhya,
> > > >
>; > > > That's very straightforward to do, particularly if you have
the
&gt; > > desired
> > > > X and Y coordinates for your nodes in a list (or a list of
lists).
> > > >
>; > > > For example, assume that you have a global variable called
&gt; > > > all-nodes-coordinates, and that its value is a list of XY
> > coordinate
> > > > pairs (with each coordinate pair specified as a list), e.g.:
&gt; > > > set all-nodes-coordinates [
> > > > [ 14.42 7.12]
&gt; > > > [ -4.47 -5.67]
&gt; > > > [ 7.88 12.29]
&gt; > > > [ 2.80 -1.07]
&gt; > > > [-12.36 1.88]
&gt; > > > [ 16.31 -6.01]
&gt; > > > [-12.91 9.70]
&gt; > > > [ 2.36 14.62]
&gt; > > > [ 1.07 -6.46]
&gt; > > > [-13.92 1.99]
&gt; > > > ]
> > > > (You could also use file-read to read a list of coordinate
pairs
> > > like
>; > > > this from a file; that's almost certainly a better approach
than
> > the
> > > > literal assignment above, especially for 100 nodes.)
> > > >
>; > > > Also, let's assume there's a breed called nodes. The following
> > > statement
> > > > would then use all-nodes-coordinates to create one node for
each
> > > > coordinate pair, and place that node on the specified XY
> > > coordinates:
> > > > create-nodes (length all-nodes-coordinates) [
> > > > let coordinate-pair (first all-nodes-coordinates)
> > > > set all-nodes-coordinates (but-first all-nodes-
coordinates)
> > > > setxy (first coordinate-pair) (last coordinate-pair)
&gt; > > > ]
> > > > Note that this statement uses the number of elements in
> > > > all-nodes-coordinates to determine the number of nodes
required,
> > and
> > > > creates those nodes. Each of those newly created nodes, in
turn,
> > > takes
&gt; > > > the first pair of coordinates from all-nodes-coordinates
(popping
> > > that
>; > > > pair from the list, so that the next node to do this will
work on
> > > the
> > > > next pair of coordinates), and use the two values in the pair
as
&gt; > > its X
> > > > and Y position.
> > > >
>; > > > I hope this helps!
&gt; > > >
>; > > > Regards,
> > > >
>; > > > Nick Bennett
> > > >
>; > > >
>; > > > --- In netlogo-users%40yahoogroups.com">netlogo-usersyahoogroups.com, "arunachalamsandhya"
> > > > <arunachalamsandhya> wrote:
&gt; > > > >
>; > > > > Hi
> > > > >
>; > > > > I have created the nodes and links and have turtles walking
> > > between
> > > > > them, but the nodes are positioned randomly . I want to
specify
> > > where
&gt; > > > > the node(i.e x and y co-ordinates for say 100 nodes) should
&gt; > > be ,please
> > > > > help me .
> > > > >
>; > > > > Thanks
&gt; > > > >
>; > > > > Sandhya
> > > > >
>; > > >
>; > >
>; >
>;

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )