Child of WikiAnalytics
No preview image
Model was written in NetLogo 5.2.0
•
Viewed 346 times
•
Downloaded 18 times
•
Run 0 times
Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)
Info tab cannot be displayed because of an encoding error
Comments and Questions
Please start the discussion about this model!
(You'll first need to log in.)
Click to Run Model
extensions [nw csv] ;;; Это описание пород агентов, которые есть в программе - к каждой породе ее собственные переменные breed [users user] ; breed [pages page] ; directed-link-breed [bonds bond] ; создание directed-link-breed [editbonds editbond] ; редактирование undirected-link-breed [friendbonds friendbond] ; undirected-link-breed [uulinks uulink] ; uulinks-own [colpages] ; users-own [agentname pages_list edit_list friend_list my_friends ] ; ;; мое имя, страницы, которые создал, страницы, которые редактировал pages-own [pagename my_author editors_list http ] ; ;; мое имя, автор и редактора bonds-own [edits] ; editbonds-own [ed] ; undirected-link-breed [unsselinks unsselink] ; - связи, основанные на том, что редактировал объект другого автора unsselinks-own [colpages] globals [wikihistory user_list step nlinks ] ; ;;; Очистили, закрыли и обнулили все, to startup clear-all ; set-default-shape users "person" ; set-default-shape pages "square" ; set-default-shape friendbonds "comment" ; file-close; set wikihistory [] ; set user_list [] ; if (file-exists? "go_ban3.gif" ) [import-drawing "go_ban3.gif" ] end ;; Загрузили данные to load_file file-open user-file while [ not file-at-end? ] [ set wikihistory lput csv:from-row file-read-line wikihistory ] file-close end ;;;;;;;;; to present reset-ticks ;; насколько мы их сдвигаем от центра set step max-pxcor / (length remove-duplicates map [first ?] wikihistory) set nlinks 0 foreach wikihistory [ visual ? layout-spring turtles links 0.1 1 0.3 tick ; ] end ;; Надо, чтобы они появлялись в нужном месте!!!! А то они все в центре to visual [flist] let agent_name first flist ;; это мы просто считали имена агентов и страниц let page_name first bf flist ;; это имя страницы let newpage 0 ;; если у нас юзера с этим именени - создаем юзера с именен ; if (not any? pages with [pagename = page_name]) [ create-ordered-pages 1 [ ;;ht ;; Не показываем страницы set size 0.8 set color green set pagename page_name ; set editors_list [] ; set newpage 1 ] ] if (not any? users with [agentname = agent_name]) [ create-ordered-users 1 [ set size 1.6 set color orange set pages_list [] ; set edit_list [] ; set agentname agent_name ; rt random 360 fd step * count users ] ] let who_user [who] of one-of users with [agentname = agent_name] ; let who_page [who] of one-of pages with [pagename = page_name] ; if newpage = 1 ;; Если страница в первый раз - значит она создается [ ask page who_page [set my_author who_user move-to user who_user rt random 360 fd 1 ] ; ask user who_user [ create-bond-to page who_page set pages_list lput who_page pages_list ] ; stop ; ] ask user who_user [ if (who_user = [my_author] of page who_page) or (member? who_user [editors_list] of page who_page) [stop] create-editbond-to page who_page set edit_list lput who_page edit_list ask page who_page [set editors_list lput who_user editors_list] ;; stop ] ;; stop end to table_output nw:set-context turtles links file-open user-new-file file-print "General information" ; file-print csv:to-row (list "Num_agents" "Num_objects" "Num_links" "Density" ) ; file-print csv:to-row (list count users count pages count links density ) file-print "Agents" ; file-print csv:to-row (list "Agentname" "userID" "PagesCreates" "Usefulness" "Edits" "Benefit" "MyLinks" "Norm-Betweenness" "PageRank" ) ; foreach reverse sort-on [nw:page-rank] users [file-print csv:to-row (list [agentname] of ? [who] of ? [length pages_list] of ? [length pages-editors pages_list] of ? ;; сколько с ним связались [length edit_list] of ? [length page-authors edit_list] of ? ;; со сколькими он связался [count my-links ] of ? [norm-betweenness] of ? precision [nw:page-rank] of ? 3 ) ] ;; Ideas ;; file-print "Objects" ; file-print csv:to-row (list "PageName" "PageID" "Author" "Edits" "Norm-Betweenness" "PageRank" ) ; foreach reverse sort-on [nw:page-rank] pages [file-print csv:to-row (list [pagename] of ? [who] of ? [agentname] of user [my_author] of ? [length editors_list] of ? [norm-betweenness] of ? [nw:page-rank] of ? ) ] file-close end ;;; ;; Выявление to-report page-authors [list1] if empty? list1 [report []] report remove-duplicates map [[my_author] of page ?] list1 end to-report pages-editors [list1] if empty? list1 [report []] report remove-duplicates reduce sentence map [[editors_list] of page ?] list1 end ;;; у нас есть список и мы хотим перевести его в имена черепах - наверное map to-report names-from-list [inlist] report map [[agentname] of user ?] inlist end ;;;; ;;; Нормированная центральности to-report norm-betweenness if count turtles > 4 [report precision (nw:betweenness-centrality / ((count turtles - 1) * (count turtles - 2) / 2 )) 2 ] report 0 end to-report centralization-btw let znm ((count turtles - 1) * (count turtles - 1) * (count turtles - 2)) / 2 ; let mx max [nw:betweenness-centrality] of turtles ; report (sum map [mx - ?] [nw:betweenness-centrality] of turtles ) / znm end to-report density if count turtles > 2 [ report (2 * count links) / ( (count turtles) * ( (count turtles) - 1) )] report 0 end to-report global-clustering-coefficient let closed-triplets sum [ nw:clustering-coefficient * count my-links * (count my-links - 1) ] of turtles let triplets sum [ count my-links * (count my-links - 1) ] of turtles report closed-triplets / triplets end to-report average_local_clustering report mean [ nw:clustering-coefficient ] of users end ;;; to OneModeGraph ask pages [ let page_id [who] of self ; let MyEditors (turtle-set in-editbond-neighbors ) ask MyEditors [ ;; если связь уже существует, то добавить к ней в переменную страницу ;; unsselink ifelse is-unsselink? unsselink [who] of self [my_author] of myself [ ask unsselink [who] of self [my_author] of myself [set colpages lput page_id colpages ] ] [ create-unsselink-with user [my_author] of myself [set colpages lput page_id [] ] ] ] die ] end to see_Btw ask turtles [ht] ;; ask links [hide-link] foreach sublist reverse sort-on [norm-betweenness] users 0 9 [ask ? [st set size 3 set label-color black set label norm-betweenness ]] end ;;; cliques to see_Bcliq ask turtles [ht] ask links [hide-link] let BigCliq one-of nw:biggest-maximal-cliques ask BigCliq [st] let BigCliqLinks links with [(member? end1 BigCliq) and (member? end2 BigCliq) ] ask BigCliqLinks [show-link] repeat 5 [layout-spring BigCliq BigCliqLinks 1 15 2] end to see_Mcliq ask turtles [ht] ask links [hide-link] foreach nw:maximal-cliques [if (count ?) > ((count one-of nw:biggest-maximal-cliques) - 1) [ let BigCliq ? let BigCliqLinks links with [(member? end1 BigCliq) and (member? end2 BigCliq) ] ask BigCliq [st] ask BigCliqLinks [show-link] layout-spring BigCliq BigCliqLinks 1 10 14 ]] ;; layout-circle users with [hidden? = false] 15 end ;; Покажи нам клики, куда входят участники с наибольшими показателями центральности to central_cliques let Mcentr sublist reverse sort-on [norm-betweenness] users 0 10 ask turtles [ht] ask links [hide-link] foreach nw:maximal-cliques [ show member? one-of ? Mcentr if ((count ?) > 5) and (any? ? with [member? one-of ? Mcentr]) ;; and (member? user SomeUser ?) [ let BigCliq ? let BigCliqLinks links with [(member? end1 BigCliq) and (member? end2 BigCliq) ] ask BigCliq [st] ask BigCliqLinks [show-link] ;; layout-spring BigCliq BigCliqLinks 1 7 1 ]] end ;;; мы умеем извлекать клики, в которые входит заданный участник to Mcliq_user [SomeUser] ask turtles [ht] ask links [hide-link] foreach nw:maximal-cliques [ if ((count ?) > 5) and (member? user SomeUser ?) [ let BigCliq ? let BigCliqLinks links with [(member? end1 BigCliq) and (member? end2 BigCliq) ] ask BigCliq [st] ask BigCliqLinks [show-link] layout-spring BigCliq BigCliqLinks 1 7 1 ]] end ;; to clustC nw:set-context users links let Centr max-one-of users [nw:betweenness-centrality] layout-radial users links Centr ;; export-view (word "../google_school_results/clust5/" [who] of Centr ".png" ) ;; export-view (word "../google_school_results/clust_view/" [who] of Centr ".png" ) ;; ask max-one-of users [nw:betweenness-centrality] [die] ask users with [count my-links = 0] [die] ;; wait 10 ;; ask Centr [die] ;; ask users with [count my-links = 0] [die] end ;;; to users_output nw:set-context users links file-open user-new-file file-print csv:to-row (list "Density" "Centrlization-betweenness" "Global-Clustering" "AverageLocalClastering" "Cliques" ) ; file-print csv:to-row (list density centralization-btw global-clustering-coefficient average_local_clustering se length nw:biggest-maximal-cliques count one-of nw:biggest-maximal-cliques ) ; file-print csv:to-row (list "Agentname" "userID" "PagesCreates" "Edits" "MyLinks" "Norm-Betweenness" "PageRank" "Clustering-coefficient" ) ; foreach reverse sort-on [nw:page-rank] users [file-print csv:to-row (list [agentname] of ? [who] of ? [length pages_list] of ? [length edit_list] of ? [count my-links ] of ? [norm-betweenness] of ? precision [nw:page-rank] of ? 3 precision [nw:clustering-coefficient] of ? 3 ) ] file-close end
There is only one version of this model, created over 8 years ago by Evgeny Patarakin.
Attached files
No files
Parent: WikiAnalytics
This model does not have any descendants.