Processing script
build_net(edgelist)
Builds a network graph using NetworkX from the given edge list and removes duplicate and directional edges.
Parameters: edgelist (list): A nested list representing the edge list.
Returns: tuple: A NetworkX graph object and a DataFrame of the processed edge list.
Source code in dsdp-lumping/processing.py
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
|
main()
Main function to execute the workflow of reading, processing, building, and formatting a network graph.
Source code in dsdp-lumping/processing.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
|
read_in(input_file)
Reads an input file and returns its contents as a nested list.
Parameters: input_file (str or Path): The file path to the input file.
Returns: list: A nested list where each sublist represents a line split by spaces.
Source code in dsdp-lumping/processing.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
rm_directions(df)
Removes directionality by marking and removing reverse edges.
Parameters: df (pd.DataFrame): A DataFrame containing source and target columns.
Returns: pd.DataFrame: DataFrame with directionality removed.
Source code in dsdp-lumping/processing.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
rm_duplicates(df)
Removes duplicate edges from the given DataFrame.
Parameters: df (pd.DataFrame): A DataFrame containing source and target columns.
Returns: pd.DataFrame: DataFrame with duplicate edges removed.
Source code in dsdp-lumping/processing.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
rm_self_edges(df)
Removes self-loop edges from the given DataFrame.
Parameters: df (pd.DataFrame): A DataFrame containing source and target columns.
Returns: pd.DataFrame: DataFrame with self-loop edges removed.
Source code in dsdp-lumping/processing.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
scy_formatting(G_in, edgelist_df, write_path)
Writes the graph to a file in .scy format, including nodes, edges, and additional formatting.
Parameters: G_in (nx.Graph): A NetworkX graph object. edgelist_df (pd.DataFrame): A DataFrame representing the edge list. write_path (Path): The file path to write the .scy formatted file.
Source code in dsdp-lumping/processing.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
|
shift_nodes(edgelist)
Shifts the node indices in an edge list by subtracting 1 from each node's index for zero-based indexing.
Parameters: edgelist (list): A nested list representing the edge list where each sublist is an edge.
Returns: list: A nested list with node indices shifted by 1.
Source code in dsdp-lumping/processing.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
|