MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / generate_ucinet

Function generate_ucinet

easygraph/readwrite/ucinet.py:37–72  ·  view source on GitHub ↗

Generate lines in UCINET graph format. Parameters ---------- G : graph A EasyGraph graph Examples -------- Notes ----- The default format 'fullmatrix' is used (for UCINET DL format). References ---------- See UCINET User Guide or http://www.analyti

(G)

Source from the content-addressed store, hash-verified

35
36
37def generate_ucinet(G):
38 """Generate lines in UCINET graph format.
39 Parameters
40 ----------
41 G : graph
42 A EasyGraph graph
43 Examples
44 --------
45 Notes
46 -----
47 The default format 'fullmatrix' is used (for UCINET DL format).
48
49 References
50 ----------
51 See UCINET User Guide or http://www.analytictech.com/ucinet/help/hs5000.htm
52 for full format information. Short version on http://www.analytictech.com/networks/dataentry.htm
53 """
54
55 n = G.number_of_nodes()
56 nodes = sorted(list(G.nodes))
57 yield "dl n=%i format=fullmatrix" % n
58
59 # Labels
60 try:
61 int(nodes[0])
62 except ValueError:
63 s = "labels:\n"
64 for label in nodes:
65 s += label + " "
66 yield s
67
68 yield "data:"
69
70 yield str(np.asmatrix(eg.to_numpy_array(G, nodelist=nodes, dtype=int))).replace(
71 "[", " "
72 ).replace("]", " ").lstrip().rstrip()
73
74
75@open_file(0, mode="rb")

Callers 1

write_ucinetFunction · 0.85

Calls 1

number_of_nodesMethod · 0.45

Tested by

no test coverage detected