internal#
adjs2graph#
- gunfolds.conversions.adjs2graph(directed, bidirected)[source]#
Convert an adjacency matrix of directed and bidirected edges to a graph
- Parameters:
directed (numpy matrix) – graph adjacency matrix for directed edges
bidirected (numpy matrix) – graph adjacency matrix for bidirected edges
- Returns:
gunfolds
format graph- Return type:
dictionary (
gunfolds
graphs)
bg2num#
dict_format_converter#
- gunfolds.conversions.dict_format_converter(H)[source]#
Convert a graph from the set style dictionary format to the integer style
- Parameters:
H (dictionary) – set style dictionary format
- Returns:
gunfolds
graph- Return type:
dictionary (
gunfolds
graphs)
>>> test = {'1': {'1': {(0, 1)}, ... '2': {(0, 1), (2, 0)}, ... '3': {(0, 1), (2, 0)}, ... '4': {(2, 0)}, ... '5': {(0, 1)}}, ... '2': {'1': {(2, 0)}, '2': {(0, 1)}, '5': {(0, 1), (2, 0)}}, ... '3': {'1': {(0, 1), (2, 0)}, '2': {(0, 1)}, '5': {(0, 1)}}, ... '4': {'1': {(2, 0)}, ... '2': {(0, 1)}, ... '3': {(0, 1)}, ... '4': {(0, 1)}, ... '5': {(0, 1)}}, ... '5': {'1': {(0, 1)}, '2': {(0, 1), (2, 0)}, '5': {(0, 1)}}} >>> dict_format_converter(test) {1: {1: 1, 2: 3, 3: 3, 4: 2, 5: 1}, 2: {1: 2, 2: 1, 5: 3}, 3: {1: 3, 2: 1, 5: 1}, 4: {1: 2, 2: 1, 3: 1, 4: 1, 5: 1}, 5: {1: 1, 2: 3, 5: 1}} >>>
edgepairs2g#
g2ian#
g2num#
g2vec#
Glag2CG#
- gunfolds.conversions.Glag2CG(results)[source]#
Converts lag graph format to gunfolds graph format, and A and B matrices representing directed and bidirected edges weights.
- Parameters:
results (dict) – A dictionary containing: - ‘graph’: A 3D NumPy array of shape [N, N, 2] representing the graph structure. - ‘val_matrix’: A NumPy array of shape [N, N, 2] storing edge weights.
- Returns:
(graph_dict, A_matrix, B_matrix)
- Return type:
tuple
graph2adj#
graph2badj#
ian2g#
nodenum#
num2CG#
- gunfolds.conversions.num2CG(num, n)[source]#
Converts a number whose binary representaion encodes edge presence/absence into a compressed graph representaion
- Parameters:
num (integer) – unique graph representation in numbers
n (integer) – number of nodes
- Returns:
gunfolds
graph- Return type:
dictionary (
gunfolds
graphs)
nxbp2graph#
ug2num#
- gunfolds.conversions.ug2num(g)[source]#
Convert non-empty edges into a tuple of (directed, bidriected) in binary format
- Parameters:
g (dictionary (
gunfolds
graphs)) –gunfolds
graph- Returns:
unique number for each graph considering directed and bidirected in binary format
- Return type:
a tuple of binary integer