kwant.graph.
make_undirected
()[source]¶undirected_graph(gr) expects a CGraph gr as input, which is interpreted as a directed graph, and returns a CGraph that is explicitely undirected, i.e. for every edge (i,j) there is also the edge (j,i). In the process, the function also removes all ‘dangling’ links, i.e. edges to or from negative node numbers.
If remove_dups == True (default value is True), any duplicates of edges will be removed (this applies to the case where there are multiple edges (i,j), not to having (i,j) and (j,i)).
The effect of the duplicate edges can be retained if calc_weights == True (default value is False), in which case a weight array is returned containing the multiplicity of the edges after the graph has been made undirected.
As a (somewhat drastic but illustrative) example, if make_undirected is applied to a undirected graph, it will return the same graph again (possibly with the order of edges changed) and a weight array with 2 everywhere. (Of course, in this case one does not need to call make_undirected ...)
make_undirected() will always return a one-way graph, regardless of whether the input was a two-way graph or not (NOTE: This restriction could be lifted, if necessary). In addition, the original edge_ids are lost – the resulting graph will have edge_ids that are not related to the original ones. (NOTE: there certainly is a relation, but as long as no-one needs it it remains unspecified)