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)
| 35 | |
| 36 | |
| 37 | def 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") |
no test coverage detected