Manipulate GEXF file format with Pharo.
Metacello new
githubUser: 'badetitou' project: 'PharoGEXF' commitish: 'main' path: 'src';
baseline: 'GEXF';
load
- Create a gexf element
gexf := GEXF new.
- Set metadata
gexf metadata creator: 'Gephi.org'. gexf metadata description: 'A Web network'.
- Add nodes
graph := gexf graph. node1 := graph createNodeWithId: '0'. node1 label: 'Hello'. node2 := graph createNodeWithId: '2'. node2 label: 'World'.
- Connect nodes
node1 connectTo: node2.
- Export file
String streamContents: [:stream | (GEXFWriter on: stream) prettyPrinting; export: gexf ]
classes := ((model allWithSubTypesOf: FamixJavaType) select: [ :d | d isStub not and: [ d isAnonymousClass not ] ]).
gexf := GEXF new.
gexf metadata creator: 'Gephi.org'.
gexf metadata description: 'my project'.
graph := gexf graph.
dicClassNode := classes collect: [ :class |
| node |
node := graph createNode.
node label: class mooseName.
class -> node
] as: Dictionary.
dicClassNode keysAndValuesDo: [ :class :node |
(class query outgoing dependencies targetsAtScope: FamixTType) do: [ :dep |
dicClassNode at: dep ifPresent: [ :aDepNode | node connectTo: aDepNode ]
]
].
'd:/seditRHDep.gexf' asFileReference writeStreamDo: [:stream |
(GEXFWriter on: stream)
prettyPrinting;
export: gexf ]