假设我有一个Graph结构,如下所示:typeGraphstruct{nodes[]intadjListmap[int][]int}//somemethodsonthestruct//constructorfuncNew()*Graph{g:=new(Graph)g.adjList=make(map[int][]int)returng}现在,我创建了该结构的一个新实例,其中:aGraph:=New()。如何访问Graph结构(aGraph)的这个特定实例的字段?换句话说,我如何访问aGraph版本的nodes数组(例如,从另一个顶级函数中)?非常感谢任何帮助!
鉴于此初始图表:importnetworkxasnxG=nx.MultiGraph()fromnodes=[0,0,1,1,1,1,1,2,3,4,5,5,5,7,8,9,10]tonodes=[1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]dupedgeind=0forx,yinzip(fromnodes,tonodes):ifG.has_edge(x,y):dupedgeind=dupedgeind+1G.add_edge(x,y,key=dupedgeind)else:dupedgeind=0G.add_edge(x,y,key=dupedge
鉴于此初始图表:importnetworkxasnxG=nx.MultiGraph()fromnodes=[0,0,1,1,1,1,1,2,3,4,5,5,5,7,8,9,10]tonodes=[1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]dupedgeind=0forx,yinzip(fromnodes,tonodes):ifG.has_edge(x,y):dupedgeind=dupedgeind+1G.add_edge(x,y,key=dupedgeind)else:dupedgeind=0G.add_edge(x,y,key=dupedge