首页 Network Analysis with igraph

Network Analysis with igraph

举报
开通vip

Network Analysis with igraph NetworkAnalysiswithigraph友情提示:这是在R语言环境下进行社会网络分析或者图论分析的工具,中间有些语句已经在新版本已经不能正常运行了,比如创建网络的语句>g<-graph(c(0,1,1,2,3,4,5,6))在igraph的0.6-2版不能运行,可以改为>g<-graph(c(1,2,1,3,3,4,5,6))也就是新版的顶点id是不能出现0的。这个教程的作者是igraph包的创始人GáborCsárdi,虽然他没有写完整,但是这个教程...

Network Analysis with igraph
NetworkAnalysiswithigraph友情提示:这是在R语言环境下进行社会网络分析或者图论分析的工具,中间有些语句已经在新版本已经不能正常运行了,比如创建网络的语句>g<-graph(c(0,1,1,2,3,4,5,6))在igraph的0.6-2版不能运行,可以改为>g<-graph(c(1,2,1,3,3,4,5,6))也就是新版的顶点id是不能出现0的。这个教程的作者是igraph包的创始人GáborCsárdi,虽然他没有写完整,但是这个教程仍具有权威性,结合帮助文件可以助你快速掌握这个分析工具。GáborCsárdiDepartmentofBiophysics,ResearchInstituteforNuclearandParticlePhysicsoftheHungarianAcademyofSciences29-33 Konkoly-Thege Miklós road, Budapest H-1121, HungaryCenterforComplexSystemsStudies,KalamazooCollege1200 Academy st, Kalamazoo, 49006, MI, USACopyright(C)2006GáborCsárdiPermissionisgrantedtocopy,distributeand/ormodifythisdocumentunderthetermsoftheGNUFreeDocumentationLicense,Version1.2oranylaterversionpublishedbytheFreeSoftwareFoundation;withnoInvariantSections,noFront-CoverTexts,andnoBack-CoverTexts.Acopyofthelicenseisincludedinthesectionentitled“GNUFreeDocumentationLicense”.TableofContentsIntroductionAshortigraphTourInstallationTheigraphdatamodelGraphsObjectsRegularGraphsCreatingGraphsRandomGraphsImportingandExportingGraphsGraphVisualizationGraph,VertexandEdgeAttributesVertexandEdgeSequencesConnectedComponentsAnalysisofCitationNetworksCentralityMeasuresPathLengthsandSimilarMeasuresGraphMotifsNetworkFlowsandRelatedConceptsGraphOperatorsLicensesforigraphandthismanualBibliographyIndexInstallationTheigraphRpackagecanbeinstalledjustlikeanyotherRpackages.Perhapstheeasiestwayistousetheinstall.packages()command.ThisdownloadseitherasourceofbinarypackageappropriatefortherunningsystemfromCRANandinstallsitbydefaulttothesystemdirectories.Thepackagecanbeloadedbytypinglibrary(igraph)afterinstallation.Iftheuserdoesn'thaverightstowritetosystemdirectoriesthelibargumentoftheinstall.packages()commandcanbeusedtosetanalternateinstallationdirectory.ItisgoodRpracticetokeeptheuser'sprivatelyinstalledpackagesinaseparatedirectory(say~/.R/library),ifthisisthecaseigraphcanbeinstalledlikethis:install.packages("igraph",lib="~/.R/library")TheRpackagesearchpathneedstobemodifiedaswelltoletRknowaboutourprivatepackagedirectory:.libPaths(c("~/.R/library",.libPaths()))Thiscommandcanalsobeaddedtothe~/.RprofilefiletosetthesearchpathautomaticallyeverytimeyoustartR.See?Startupand?.libPaths()formoreinformationaboutR'sstartupmechanismandthewaydirectoriesaresearchedforpackagesand?install.packagesaboutinstallingRpackages.TheigraphdatamodelDirectedgraphsUndirectedgraphsExamplesThissectionintroducestheigraphdatamodel.Itisrecommendedthatthereadershouldbefamiliarwiththismodelofcomputationtounderstandthesemanticsoftheigraphfunctionsbetter.Anigraphgraphiseitherdirectedorundirected,igraphcannothandlemixedgraphswithbothdirectedandundirectededges.DirectedgraphsTheigraphdatamodelisslightlydifferentfordirectedandundirectedgraphs,westartwiththedirectedcase.Inigraphverticesareidentifiedbyvertexids:integernumberbetweenzeroand|V|-1,if|V|isthenumberofverticesinthegraph.Thusthenumberingofvertexidsisalwayscontinual,alligraphoperationsongraphskeepthisimportantproperty.Directedigraphedgesareorderedpairsorvertexids.Adirectedgraphisanorderedmultisetofdirectededgesandsomeadditionalmetadata:thenumberofverticesinthegraphandabooleantagtomarkthegraphasdirected.Hereisanexampleofadirectedigraphgraph:(vertices:6,directed:yes,((0,2),(2,2),(2,3),(3,3),(3,4),(3,4),(4,1)))Justliketheverticeshavevertexids,igraphedgesalsohaveids:edgeidsareintegernumbersbetweenzeroand|E|-1,|E|isthenumberofedgesinthegraph.UndirectedgraphsAnundirectedigraphedgeisatwo-elementorone-elementsetofvertexids.Thetwoelementsetisanon-loopedge,ie.theedgeconnectsdifferentvertices,whileloopedgesarerepresentedwithasingle-elementset.Anundirectedgraphisanorderedmultisetofundirectededges,plustheusualmetadata:thenumberofverticesandthefactthatthegraphisundirected.Hereisanexampleforanundirectedgraph:(vertices:6,directed:no,({0,2},{2},{2,3},{3},{3,4},{3,4},{4,1}))Thisgraphcontainsbothloopedges({2}and{3},ie.(2-2)and(3-3))andmultipleedges({3,4}twice).ExamplesWegivesomesimpleexamplesonhowthisdatamodelisusedincomputations.Thefirstexampleistheare.connected()function,thisdecideswhethertwoverticesareconnectedbyanedge.LetsassumethatG1andG2arethegraphsfromtheprevioustwosections,G1isthedirected,G2theundirectedgraph.Nowifwecheckwithare.connected()whethervertices0and2areconnectedinG1,thefunctionsearchesforthe(0,2)directedpair,andsinceitfindsititreturnspositiveresult.IfthesamesearchisperformedonG2,thefunctionsearchesforthe{0,2}setandtheresultis,again,positive.Nowitisperhapsobviousbynowthatifwesuppplytheverticesintheoppositeorder,ie.2and0theninG1the(2,0)orderedpairisrequested,sotheanswerisnegative.ForG2{0,2}={2,0}issearchedagain,theanswerisstillpositive.Anothersimpleexampleistheneighbors()command,thiscanbeusedtofindtheneighboringverticesofavertex.neighbors()(likemanyotherfunctionsinigraph)hasaparametercalledmode.Thisparameterdefineshowthesearchisperformedindirectedgraphs.Letusassumethatweareinterestedintheneighborsofvertex3.Ifmodeisoutthenthegraph'sedgelist(whichisamultiset)issearchedforelementshaving3inthefirstpositionoftheorderedpairandreturnsthevertexidsinthesecondpositionintheseelements.Sotheansweris(3,4,4).Nowifmodeisinthentheroleofthefirstandsecondpositionsisexchangedand(2,3)isreturned.Thethirdpossiblevalueofmodeisall,inthiscasepairshaving3ateitheratthefirstorsecondpositionsaresearchedandtheothervertexidinthepairisreturned:(2,3,4,4).Notethat3isreturnedonlyonceevenifitisfoundbothways.Thisofcoursecorrespondstothenormalgraphtheoreticconventions.Themodeargumentisalwaysignoredwhendealingwithundirectedgraphs,asthesegraphsstoreanedgeasanunorderedpair(ie.aset).Forexamplerunningneighbors()ongraphG2andvertex3,theresultis(2,3,4,4).Notethatifwesetmodetoallonadirectedgraphthatessentiallymeansthatweusethecorrespondingundirectedgraphforcalculation.Alsonotethatthecorrespondingundirectedgraphalwayshavethesamenumberofedgesasthedirectedcounterpart,eg.ifthedirectedgraphcontains(3,4)and(4,3)theseedgesmaketwo{3,4}edgesintheundirectedgraph.Someigraphfunctionshaveamodeforotherpurposes:eg.graph.tree()andgraph.star().GraphsObjectsigraphusesgraphobjectstorepresentgraphs,agraphobjectisanopaquetypeinthesensethatusersarenotexpectedtomanipulategraphobjectsdirectly.Insteadigraphprovidesfunctionstocreateandmanipulategraphobjects.Thisorganizationhastheadvantagethattheinternalrepresentationcanbechangedanytimewithoutbreakinganycode,assumingtheuserskeeptherules.Tofacilitatetheproperusageofigraphgraphobjectswedonotpresenttheinternalgraphrepresentationhere.Thereareseveralfunctionswhichcreategraphobjects,hereisaveryincompletelistofthem:graph(),graph.star(),graph.tree(),graph.adjacency(),barabasi.game().Forexamplegraph()createsadirectedgraphfromalistofedges:>g<-graph(c(0,1,1,2,3,4,5,6))>gVertices:7Edges:4Directed:TRUEEdges:[0]0->1[1]1->2[2]3->4[3]5->6GraphobjectshaveanRclassigraphandtheis.igraphfunctioncanbeusedtocheckthatanRobjectisanigraphgraphobject:>class(graph(1:10))[1]"igraph">is.igraph(graph(1:10))[1]TRUE>is.igraph(1:10)[1]FALSERegularGraphsEmptygraphsFullgraphsStarsandRingsLatticesTreesTheGraphAtlasEmptygraphsigraphprividessomewaysforgeneratingregulargraphstrucures:lattices,trees,etc.Letusbeginwiththesimplestcase:theemptygraph:>g<-graph.empty()Thiscommandcreatesanemptygraphandstoresitinavariablenamedg.Ifyoutypeinthenameofavariablecontainingagraphobject,Rprintssomeinformationaboutthegraph,anditsedgelist:>gVertices:0Edges:0Directed:TRUEThissmallexampleillustratesanumberofthings:emptygraphscanbecreatedbythegraph.empty()command;bydefaultthiscommandcreatesagraphwithnoverticesandnoedges(wellthisiswhatthewordemptymeans);bydefaultthiscommandcreatesdirectedgraphs.graph.empty()hasanoptionalparameter:n,thenumberofverticesinthegraph.(Agraphwithnon-zeronumberofverticesandnoedgesisstillcalledandemptygraph.)>g<-graph.empty(n=10)>gVertices:10Edges:0Directed:TRUEThisisagraphwithtenverticesandzeroedges.FullgraphsAfullgraphiscompletelytheoppositeofemptygraphs:itcontains(onecopyof)allpossibleedges.Afullgraphcanbecreatedbythegraph.full()command.Bydefaultitcreatesundirectedgraphswithnoloop(ie.self)edges:>f<-graph.full(3)>fVertices:3Edges:3Directed:FALSEEdges:[0]0--1[1]0--2[2]1--2ThecommandhasadirectedparameterwhichcanbesettoTRUEtogenerateddirectedgraphs:>f<-graph.full(3,directed=TRUE)>fVertices:3Edges:6Directed:TRUEEdges:[0]0->1[1]0->2[2]1->0[3]1->2[4]2->0[5]2->1Notethatigraphprintsundirectededgeswith“--”anddirectedoneswith“->”,stressingthattheorderofthevertexidsintheedgesareimportantonlyindirectedgraphs.Hereisanexampleofanundirectedfullgraph:Someigraphfunctionsprovideinformationaboutthestructureofagraph,is.directed()returnsalogicalconstant,TRUEistheargumentgraphisdirectedandFALSEotherwise.are.connected()givesTRUEifthegivenverticesareconnectedwithanedgeandFALSEotherwise.Itworksslightlydifferentlyfordirectedandundirectedgraphs;forundirectedgraphstheorderofthevertexidparametersdoesn'tmatter;fordirectedgraphitsearchesforanedgefromthefirstvertextothesecond:>is.directed(graph.full(10))[1]FALSE>is.directed(graph.full(10,directed=TRUE))[1]TRUE>g<-graph.full(10)>are.connected(g,1,4)[1]TRUE>g<-graph.empty(n=10)>are.connected(g,1,4)[1]FALSEIfagraphisverybig,thenitisprobablynotagoodideatolistitsedgestothescreen.Inthiscasethestandardsummary()functioncanbeusedtoprintsomeusefulinformationaboutthegraph:>big<-graph.full(1000)>summary(big)Vertices:1000Edges:499500Directed:FALSEgraph.full()alsohasaloopsparametertoincludeloopedgesingraph.graph.full()nevercreatesgraphswithmultipleedges.StarsandRingsInastargraph,asingledistinguishedvertexisconnectedtoeveryotherverticesandtherearenootheredgespresent.Inigraphthreetypesofstargraphscanbecreated,themodeargumentdecideswhichonetogenerate:increatesadirectedgraphinwhicheveryedgepointstothedistinguishedvertex,outcreatesadirectedgraphwithoppositedirectednessandundirectedcreatesanundirectedstar. Thegraph_ring()commandcancreatevariousringgraphs(ie.one-dimensionallattices).Thedirected,mutualandcircularparametersgivetheexactshapeofthegraph,seethefigurefordetails.LatticesAnn-dimensionallattice(sometimesalsocalledgrid)isagraphinwhichtheverticesareplacedattheintegercoordinatepointsofthen-dimensionalEuclideanspaceandeachvertexconnectstoverticeswhichareexactlyoneunitawayfromit.Ie.ifthelatticeistwodimensionalandthelengthofthelatticeis5alongthefirstand3alongtheseconddimension,thenithas15verticesandthey'replacedatcoordinates(1,1),(1,2),(1,3),(2,1),…(5,3)andtwoverticesareconnectedifthedifferenceofoneoftheircoordinatesisoneorminusoneandalltheirothercoordinatesareexactlythesame.Inigraphlatticesaregeneratedwithgraph.lattice().Ithastwodifferentforms.Inthefirstform,theparameterlength,thelengthofthelatticealongeverydimensionandparameterdim,thedimensionalityofthelatticearegiven.Inthesecondformtheparameterdimvectorisgiven,thiscontainsthelengthofthelatticealongeachdimensionsseparately.Thedefaultisthesecondform.Thefollowingtwoareequivalent,theycreatethesamegraphs:>l1<-graph.lattice(length=5,dim=2)>l2<-graph.lattice(c(5,5))Thesecondformisobviouslymoregeneral.graph.lattice()generatesnon-circularlatticesbydefaults.Inacircularlatticethedifferenceofthecoordinatesoftheverticesiscalculatedmodulothesizeofthelatticealongthegivendimensionsoforexampleinthecircular5x3twodimensionallatticevertices(1,1)and(1,3)arealsoconnectedjustlike(1,1)and(5,1).Thecircularparameterofgraph.lattice()canbesettoTRUEtogeneratecirculargraphs.graph.lattice()generatesundirectedgraphsbydefault,butthedirectedparametercanbesettoTRUEtogeneratedirectedlattices.Thedirectionoftheedgesissuchthattheedgepointsfromthevertexwiththesmallervertexidtothevertexwiththelargervertexid.IfthemutualparameterisalsosettoTRUEthentwodirectededgesarecreatedinbothdirection.Treesigraphhassomelimitedcapabilitiesforcreatingtreeswiththegraph.tree()function.Theonlykindoftreesthisfunctioncangeneratearealmostcompleteregulartrees.Inacompleteregulartreeeveryvertexhasthesamenumberofchildrenexceptfortheleafswhichhavenochildrenatall.Analmostcompleteregulartreeismadefromacompleteregulartreebyremovingsomeoftheleafsfromit.Thedirectednessoftheedgesoftreeisdeterminedbythemodeparameter.Seethefigureforthepossiblevaluesofthisparameter.TheGraphAtlasigraphcangenerategraphsfromthebookAnAtlasofGraphsbyRolandC.ReadandRobinJ.Wilson.Theatlascontainsallundirectedgraphswithuptosevenvertices,numberedfrom0upto1252.Thegraphsarelisted:1.inincreasingorderofnumberofnodes;2.forafixednumberofnodes,inincreasingorderofthenumberofedges;3.forfixednumbersofnodesandedges,inincreasingorderofthedegreesequence,forexample111223<112222;4.forfixeddegreesequence,inincreasingnumberofautomorphisms.Hereisarandomselectionfromthegraphatlas:CreatingGraphsEdgelistsAdjacencymatricesRealworldexamplesEdgelistsigraphgraphsaremostoftencreatedbygivingthelistoftheedgestothegraph()function:>g1<-graph(c(0,1,1,2,2,2,2,3))>g1Vertices:4Edges:4Directed:TRUEEdges:[0]0->1[1]1->2[2]2->2[3]2->3ThedirectedparametercanbesettoFALSEtocreateundirectedgraphs:>g1<-graph(c(0,1,1,2,2,2,2,3),directed=FALSE)>g1Vertices:4Edges:4Directed:FALSEEdges:[0]0--1[1]1--2[2]2--2[3]2--3Bydefaultthenumberofverticesinthegrapharedeterminedfromtheedgelistvector,itisthelargestvertexidplusone.Thenparametercanbesuppliedtooverridethis.Givingasmallnumberherethanthelargestvertexidplusoneintheedgelisthasnoeffectatall:>graph(c(0,1,1,2,2,2,2,3,),n=10)Vertices:10Edges:4Directed:TRUEEdges:[0]0->1[1]1->2[2]2->2[3]2->3>graph(c(0,1,1,2,2,2,2,3,),n=1)Vertices:4Edges:4Directed:TRUEEdges:[0]0->1[1]1->2[2]2->2[3]2->3Ifyouhappentohavetheedgelistofagraphinatwo-columnmatrix,thenyoucancreateanigraphgraphbysimplygivingthetransposedmatrixtograph():>edgelist[,1][,2][1,]01[2,]12[3,]22[4,]23>graph(t(edgelist))Vertices:4Edges:4Directed:TRUEEdges:[0]0->1[1]1->2[2]2->2[3]2->3The“inverse”operationofgraph()isget.edgelist();thistakesagraphobjectasanargumentandreturnsanedgelistinatwo-columnmatrix.AdjacencymatricesAnAadjacencymatrixisarepresentationofadirectedgraph,itisa|V|x|V|matrix,|V|beingthenumberofverticesandA(i,j)is1ifthereisanedgefromvertexi-1tovertexj-1andzerootherwise.Thisdefinitioncanbegeneralizedtorepresentmultipleedges,ie.A(i,j)isthenumberofedgesfromvertexi-1tovertexj-1,andcanrepresentundirectedgraphsaswell.igraphprovidesthegraph.adjacency()tocreategraphsfromadjacencymatrices.Itsonlyrequiredparameteristheadjacencymatrix,andithasanoptionalmodeparameterwhichspecifieshowtointerprettheadjacencymatrix.Itspossiblevalues:directedAdirectedgraphwillbecreated,A(i,j)givesthenumberofedgesfromvertexi-1tovertexj-1.undirectedAnundirectedgraphwillbecreated,thenumberofedgesaddedfromvertexi-1tovertexj-1isthemaximumofA(i,j)andA(j,i).maxAnundirectedgraphwillbecreated,thenumberofedgesaddedfromvertexi-1tovertexj-1isthemaximumofA(i,j)andA(j,i).Thismodeisthesameasundirected.minAnundirectedgraphwillbecreated,thenumberofedgesfromvertexi-1tovertexj-1istheminimumifA(i,j)andA(j,i).upperAnundirectedgraphwillbecreated,thenumberofedgesbetweenverticesisgivenbytheuppertriangleoftheadjacencymatrix,thelowertriangleisignored.(Thediagonalisconsideredtobepartoftheuppertrianglesoloopedgesmightbecreated.)lowerAnundirectedgraphwillbecreated,thenumberofedgesbetweenverticesisgivenbythelowertriangleoftheadjacencymatrix,theuppertriangleisignored.(Thediagonalisconsideredtobepartofthelowertrianglesoloopedgesmightbecreated.)plusAnundirectedgraphwillbecreated,thenumberofedgesfromvertexi-1tovertexj-1isgivenbyA(i,j)+A(j,i).Herearesomeexamples,weusethesameadjacencymatrixwithdifferentmodeparameter.TODOgraph.adjacency()alsoacceptslogicalmatrices,theTRUEvaluecorrespondsto1andFALSEisinterpretedas0.ThiscanbeusedtocreategraphbasedonathresholdontheA(i,j)values:>M<-matrix(runif(100),nr=10)>graph.adjacency(M>=0.9)Vertices:10Edges:13Directed:TRUEEdges:[0]0->7[1]1->1[2]1->4[3]1->5[4]3->0[5]4->0[6]4->2[7]4->7[8]6->8[9]7->4[10]7->5[11]7->7[12]9->7The“inverse”operationofgraph.adjacency()isget.adjacency(),thistakesagraphandreturnsanadjacencymatrix.Forundirectedgraphsitalsotakesanoptionalargumentcalledtype.Ifitsvalueisboththenasymmetricadjacencymatrixisreturned,forupperonlytheuppertriangleoftheadjacencymatrixwillcontainthedata(includingthediagonal),thelowertriangleisfilledwithzeros.loweristheopposite:thelowertriangle(includingthediagonal)containsdata,theuppertriangleisfilledwithzeros.RealworldexamplesAsimplegraphAgraphwithattributesThissectionshowadetailedexampleonhowtoconvertyourdataintoanigraphgraph.Supposeyou'rejustbackfromyourfieldresearchoryou'vefoundsomenicepieceofdataonlineandyouwanttoturnyourdataintoanigraphgraphobjecttoplaywithit.Althoughwecannotgiveageneralreceiptwhichworksinallcases,thefollowingexampleshouldprovideyouenoughguidelinestohandlealmostanytypeofdatayou'llfind.Ifyourdataisnotinanelectronicformat,thenyouneedtotypeitinintooneormorefilesfirst.Thiscanbedonebyanybasiceditoryouarefamiliarwith,forexamplenotepadorwordpadonMicrosoftoperatingsystems,emacsorvionUnix-likesystems.YoucanalsouseaspeadsheetprogramifyoulikebutmakesurethatitcanexportCSV(commaseparatedvalue)files.YoucanalsotypeinyourdatadirectlyintoR,inthefirstexamplewewillshowyouhowthiscanbedone.AsimplegraphIfyouhaveagraphwithnottoomanyverticesandedges,youcantypeitindirectlyintoR.(Thisisofcoursepossibleforlargergraphsaswell,butwedonotrecommenditastexteditorsaregenerallymuchmorecomfortable.)Firstwewillcreateadataframecontainingaweightedsymbolicedgelist,andthenwewilltransformthedataframeintoanigraphgraph.Incaseyoudon'tknowwhatdataframesare,theyaretablesandgenerallyeachrowinthetablecorrespondstoanindividual(orsomethingelseifyouhavenon-socialnetworks)andeachcolumnisavariable,atraitorobservationoftheindividuals.Adataframecanbeeditedwiththeedit()functioninR,wewillusethistotypeinourdata.>data<-edit(data.frame())NotethattheappearenceoftheeditwindowmaybeslightlydifferentondifferentoperatingsystemsorGUIs.Youcanresizetheeditwindowtohaveathirdcolumnfortheweigthsorsimplyusethetabulatorkeytomovetothethirdcolumn.Nowfillthefieldswithyourgraphdata.Clickontheheadertosetthenamesofthecolumns,thesewillbethenamesoftheedgeattributes.Clickonthe'Quit'buttonifyou'reready.Hereisanexample:Nowthedatvariablecontainsadataframewithyourdata.Youcancreateanigraphgraphobjectfromthesebycallingthegraph.data.frame():>g<-graph.data.frame(dat,directed=FALSE)>gVertices:5Edges:10Directed:FALSEEdges:[0]0--1[1]0--2[2]0--3[3]0--4[4]1--2[5]1--3[6]1--4[7]2--3[8]2--4[9]3--4>V(g)$name[1]"Alice""Bob""Cecil""Denis""Eszter">E(g)$weight[1]1-111-11111-1AgraphwithattributesLetussupposethatyou'vecolledtedinformationaboutthesocialnetworkofasmallgroup,saytenpeople.Youwanttostorevariousattributesofthepeopleanddifferenttypesofrelations(likefriendship,businessrelationship,etc.)amongthem.Youdecidetostoreeverythinginasinglegraph,forsimplicity.Thefollowingtraitsarecollectedaboutthepeopleintheexperiment:name,age,genderandRwillassignnumericidstothem.Hereisthecompletedataset:Thenexttablecontainsallthedifferentrelationsamongthesepeople,somerelationsarebinary(YESorNO,eg.theoneindicatingwhetherornottwopeopleworkinthesameroom),otherslikefriendshipmighthavevaluesbetweenzeroandfive.Notethatwewillhaveadirectedgraphbecausetherelationsarenotsymmetric.Ie.accordingtoline1AliceasksBobveryrarelyforadvice,but(line2)BobseeksAlice'sadvicequiteoften.LetusassumethatthisdataissavetoafileinCSVformat,thissimplymeansthattheentriesinthetableareseparatedbycommas.Thefirstfile(traits.csv)containsthetraitsandlookslikethis:AliceAnderson,48,FBobBradford,33,MCecilConnor,45,FDavidDaugher,34,MEsmeraldaEscobar,21,FFrankFinley,36,MGabiGarbo,44,FHelenHunt,40,FIrisIrving,25,FJamesJones,47,Mandthesecondfilewhichcontainstherelationslookslikethis:Bob,Alice,N,4,4Cecil,Bob,N,5,5Cecil,Alice,Y,5,5David,Alice,N
本文档为【Network Analysis with igraph】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_665333
暂无简介~
格式:doc
大小:425KB
软件:Word
页数:73
分类:互联网
上传时间:2012-08-02
浏览量:41