Compare turtle labels in linked network

Hello,

I am trying to compare turtle labels in a social network.

The follow code is accepted grammatically by Netlogo but the logical test is not being carried out
Is there something obvious I have missed? i am wondering if the problem is that the turtles have multiple linked neighbors and I need to ask each neighbor in turn?

Many thanks for any suggestions

ask turtles with [contributor?]
[
ifelse label = [label] of link-neighbors ;; compare labels for affinity
[set affinity 15 ]
[set affinity 5 ]

[label] of link-neighbors is stored as a list.

For example, if the network consists of agents with labels A, B, C and the agent of interest has label A with 5 neighbors having random labels, then the comparison will look like the following:

Check if A = [B,C,A,A,B]

Since LHS is not equal to RHS, this always return false.

If you are interested in checking whether there is at least one other neighbor with label equal to the agent, then you can use the member? command as follows:

This checks if the label is a member of the list of labels of the link-neighbors

@Pradeesh’s solution should work. You could also do:

This checks if the asking agent has any link-neigbhors with the same label as itself.

Thank you, that is very helpful :grinning:

Thank you, also very helpful!