MedidasCentrales

MedidasCentrales preview image

1 collaborator

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.2.1 • Viewed 42 times • Downloaded 8 times • Run 0 times
Download the 'MedidasCentrales' modelDownload this modelEmbed this model

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

extensions [nw]
breed[nodes node]

nodes-own[nombre ]
globals [nombres
select]


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;; layouts;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to spring
  layout-spring turtles links .25 1 calibrar
end 

to circle
  layout-circle nodes 10
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;medidas centrales ;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to closeness
  ask nodes [

    set label precision (   nw:closeness-centrality) 2
  ]
end 

to cluster
  ask nodes [

    set label precision ( nw:clustering-coefficient) 5
  ]
end 

to rank
  ask nodes [

    set label precision ( nw:page-rank) 2
  ]
end 

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;; Varios ;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to nombre-nodos
  ask nodes[
    set label nombre]
end 

to sin-nombre
  ask nodes[
    set label ""]
end 

to degree
  ask nodes [
    let grado count my-links
    set label grado
    set size (sqrt grado) + 0.5
    set color scale-color green grado maxi 0
  ]
end 

to poner-nombres
  set nombres [ "Juan" "pedro" "maría" "valentina" "daniela"
               "laura"  "mateo" "sharon" "ana" "cristian"  "aleja"
            "vanesa"
  "liliana"
  "claudia"
   "alejo"
 "david"
   "germán"
   "raul"
   "gladys"
   "alvaro"
 "marta"
   "santiago"
"gabriel"
"alicia"
   "arturo"]




  foreach (n-values (count nodes) [ i -> i ])
  [ i ->
           let tam length nombres
           ask node i
           [set label (item (i mod tam) nombres)
            set nombre (item (i mod tam) nombres)]
  ]
end 



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;; Redes;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

to cargar-grafo
  ca
ask patches [set pcolor white ]
  nw:load user-file nodes links
   ask nodes [
    set shape "dot"
    set color lime
    set size 2
    set label who
    set label-color black
  ]
end 

to small-world
   ca
 ask patches [set pcolor white]
  nw:generate-watts-strogatz nodes links 24 2 0.1
  ask nodes [
    set shape "dot"
    set color lime
    set size 2
    set label who
    set label-color black
  ]
end 

to red-random
   ca
 ask patches [set pcolor white]
  nw:generate-random nodes links 24 0.3
  ask nodes [
    set shape "dot"
    set color lime
    set size 2
    set label who
    set label-color black
  ]
end 

to hubs
  ca
 ask patches [set pcolor white]
  nw:generate-preferential-attachment nodes links 24 1 [
   set shape "dot"
    set color lime
    set size 2
    set label who
    set label-color black ]
end 

to completo
  ca
 ask patches [set pcolor white]
  ask n-of 24 patches [sprout-nodes 1]
  ask nodes [create-links-with other nodes]
  ask nodes [
     set shape "dot"
    set color lime
    set size 2
    set label who
    set label-color black
  ]
end 

to legara

  ca
  ask patches [set pcolor white]
  ask n-of 25 patches [sprout-nodes 1]
  ask nodes [
    set shape "dot"
    set color lime
    set size 2
    set label who
    set label-color black ]
  ask turtle 0[ create-link-with (turtle 1)]
  ask turtle 0[ create-link-with (turtle 4)]
  ask turtle 0[ create-link-with (turtle 5)]

  ask turtle 1[ create-link-with (turtle 3)]
  ask turtle 1[ create-link-with (turtle 2)]
  ask turtle 1[ create-link-with (turtle 4)]

  ask turtle 3[ create-link-with (turtle 10)]

  ask turtle 4[ create-link-with (turtle 6)]
  ask turtle 4[ create-link-with (turtle 7)]
  ask turtle 4[ create-link-with (turtle 8)]
  ask turtle 4[ create-link-with (turtle 9)]

  ask turtle 8[ create-link-with (turtle 19)]
  ask turtle 8[ create-link-with (turtle 23)]
  ask turtle 8[ create-link-with (turtle 24)]

  ask turtle 10[ create-link-with (turtle 11)]
  ask turtle 10[ create-link-with (turtle 12)]
  ask turtle 10[ create-link-with (turtle 13)]

  ask turtle 12[ create-link-with (turtle 13)]
  ask turtle 12[ create-link-with (turtle 14)]
  ask turtle 12[ create-link-with (turtle 15)]

  ask turtle 13[ create-link-with (turtle 16)]

  ask turtle 16[ create-link-with (turtle 17)]
  ask turtle 16[ create-link-with (turtle 18)]

  ask turtle 19[ create-link-with (turtle 20)]
  ask turtle 19[ create-link-with (turtle 21)]
  ask turtle 19[ create-link-with (turtle 22)]

  ask turtle 23[ create-link-with (turtle 24)]

  ask turtle 0 [set nombre "Juan"]
  ask turtle 1 [ set nombre "pedro"]
  ask turtle 2  [ set nombre "maría"]
  ask turtle 3 [set nombre "valentina"]
  ask turtle 4 [set nombre "daniela"]
  ask turtle 5 [set nombre "laura"]
  ask turtle 6 [set nombre "mateo"]
  ask turtle 7 [set nombre "sharon"]
  ask turtle 8 [set nombre "ana"]
  ask turtle 9 [set nombre "cristian"]

   ask turtle 10 [set nombre "aleja"]
  ask turtle 11 [ set nombre "vanesa"]
  ask turtle 12  [ set nombre "liliana"]
  ask turtle 13 [set nombre "claudia"]
  ask turtle 14 [set nombre "alejo"]
  ask turtle 15 [set nombre "david"]
  ask turtle 16 [set nombre "germán"]
  ask turtle 17 [set nombre "raul"]
  ask turtle 18 [set nombre "gladys"]
  ask turtle 19 [set nombre "alvaro"]


  ask turtle 20 [set nombre "marta"]
  ask turtle 21 [ set nombre "santiago"]
  ask turtle 22  [ set nombre "gabriel"]
  ask turtle 23 [set nombre "alicia"]
  ask turtle 24 [set nombre "arturo"]
end 

to mover-nodos
  ifelse mouse-down? [
    ; if the mouse is down then handle selecting and dragging
    handle-select-and-drag
  ][
    ; otherwise, make sure the previous selection is deselected
   set select nobody
    reset-perspective
  ]
  display ; update the display
end 

to handle-select-and-drag
  ; if no turtle is selected
  ifelse select = nobody  [
    ; pick the closet turtle
    set select min-one-of turtles [distancexy mouse-xcor mouse-ycor]
    ; check whether or not it's close enough
    ifelse [distancexy mouse-xcor mouse-ycor] of select > 1 [
      set select nobody ; if not, don't select it
    ][
      watch select ; if it is, go ahead and `watch` it
    ]
  ][
    ; if a turtle is selected, move it to the mouse
    ask select [ setxy mouse-xcor mouse-ycor ]
  ]
end 

to-report maxi
  report max [count my-links] of nodes
end 

to-report mini
  report min [count my-links] of nodes
end 

to tabla-grados
  let listado []
  ask turtles [
    let cl precision count my-links 2
    set listado fput   (list nombre cl) listado
  ]
  print "       "
  let lista sort-by [[ lista1 lista2 ] -> last lista1 > last lista2]  listado
  foreach lista print
end 

to tabla-closeness
  let listado []
  ask turtles [
    let cl precision nw:closeness-centrality 2
    set listado fput   (list nombre cl) listado
  ]
  print "       "
  let lista sort-by [[ lista1 lista2 ] -> last lista1 > last lista2]  listado
  foreach lista print
end 

to tabla-page-rank
  let listado []
  ask turtles [
    let cl precision nw:page-rank 2
    set listado fput   (list nombre cl) listado
  ]
  print "       "
  let lista sort-by [[ lista1 lista2 ] -> last lista1 > last lista2]  listado
  foreach lista print
end 

to tabla-clustering
  let listado []
  ask turtles [
    let cl precision nw:clustering-coefficient 2
    set listado fput   (list nombre cl) listado
  ]
  print "       "
  let lista sort-by [[ lista1 lista2 ] -> last lista1 > last lista2]  listado
  foreach lista print
end 

There is only one version of this model, created over 2 years ago by Alfonso Meléndez.

Attached files

File Type Description Last updated
MedidasCentrales.png preview Preview for 'MedidasCentrales' over 2 years ago, by Alfonso Meléndez Download

This model does not have any ancestors.

This model does not have any descendants.