pycatflow/viz.py
def nodify(data, sort_by="frequency"):
    """
    Takes data and creates a list containing information about the nodes for the graph.

    Parameters:
    data (dict): output of the read_file/read functions, a dictionary with keys the temporal data, and values a dictionary with keys of the item and values or the frequency of the item or a tuple with the frequency and the category
    sort_by (str): "frequency" or "alphabetical" or "category", defaults to "frequency"

    Returns:
    (list): A list containing information about the nodes for the graph
    """
    d = {}
    if sort_by == "frequency":
        for item in data.items():
            if type(item[1][next(iter(item[1]))]) == tuple:
                d[item[0]] = {k: v for k, v in sorted(item[1].items(),
                                                      key=lambda x: (-x[1][0], x[0]),
                                                      reverse=False)}
            else:
                d[item[0]] = {k: v for k, v in sorted(item[1].items(),
                                                      key=lambda x: (-x[1], x[0]),
                                                      reverse=False)}
    elif sort_by == "category":
        for item in data.items():
            d[item[0]] = {k: v for k, v in sorted(item[1].items(), key=lambda x: (x[1][1], x[0]), reverse=False)}
    elif sort_by == "alphabetical":
        for x, y in data.items():
            d[x] = {k: v for k, v in sorted(y.items())}

    labels = [list(x[1].keys()) for x in d.items()]
    values = [[y[0] if type(y) == tuple else y for y in x[1].values()] for x in d.items()]
    categories = [[y[1] if type(y) == tuple else "null" for y in x[1].values()] for x in d.items()]
    headers = list(d.keys())
    node_x = 0
    count = 0
    count2 = 0

    nodes = []
    sequence = {}

    for l, v, s in zip(labels, values, categories):
        if count2 < len(labels):
            count2 += 1
        for x, y, z in zip(l, v, s):
            nodes.append(Node(count, count2, 0, 0, y, y, 1, x, z))
            count += 1
           
    for n in nodes:
        if n.label in sequence.keys():
            sequence[n.label].append(n.index)
        else:
            sequence[n.label] = []
            sequence[n.label].append(n.index)
    
    return [headers, nodes, sequence]

    Takes data and creates a list containing information about the nodes for the graph.

    Parameters:
    data (dict): output of the read_file/read functions, a dictionary with keys the temporal data, and values a dictionary with keys of the item and values or the frequency of the item or a tuple with the frequency and the category
    sort_by (str): "frequency" or "alphabetical" or "category", defaults to "frequency"

    Returns:
    (list): A list containing information about the nodes for the graph
    
Takes data and creates a list containing information about the nodes for the graph.

A list containing information about the nodes for the graph
Takes data and creates a list containing information about the nodes for the graph . A list containing information about the nodes for the graph
def nodify(data, sort_by="frequency"):
    d = {}
    if sort_by == "frequency":
        for item in data.items():
            if type(item[1][next(iter(item[1]))]) == tuple:
                d[item[0]] = {k: v for k, v in sorted(item[1].items(),
                                                      key=lambda x: (-x[1][0], x[0]),
                                                      reverse=False)}
            else:
                d[item[0]] = {k: v for k, v in sorted(item[1].items(),
                                                      key=lambda x: (-x[1], x[0]),
                                                      reverse=False)}
    elif sort_by == "category":
        for item in data.items():
            d[item[0]] = {k: v for k, v in sorted(item[1].items(), key=lambda x: (x[1][1], x[0]), reverse=False)}
    elif sort_by == "alphabetical":
        for x, y in data.items():
            d[x] = {k: v for k, v in sorted(y.items())}
    labels = [list(x[1].keys()) for x in d.items()]
    values = [[y[0] if type(y) == tuple else y for y in x[1].values()] for x in d.items()]
    categories = [[y[1] if type(y) == tuple else "null" for y in x[1].values()] for x in d.items()]
    headers = list(d.keys())
    node_x = 0
    count = 0
    count2 = 0
    nodes = []
    sequence = {}
    for l, v, s in zip(labels, values, categories):
        if count2 < len(labels):
            count2 += 1
        for x, y, z in zip(l, v, s):
            nodes.append(Node(count, count2, 0, 0, y, y, 1, x, z))
            count += 1
    for n in nodes:
        if n.label in sequence.keys():
            sequence[n.label].append(n.index)
        else:
            sequence[n.label] = []
            sequence[n.label].append(n.index)
    return [headers, nodes, sequence]
def nodify ( data , sort_by = "frequency" ) : d = { } if sort_by == "frequency" : for item in data . items ( ) : if type ( item [ 1 ] [ next ( iter ( item [ 1 ] ) ) ] ) == tuple : d [ item [ 0 ] ] = { k : v for k , v in sorted ( item [ 1 ] . items ( ) , key = lambda x : ( - x [ 1 ] [ 0 ] , x [ 0 ] ) , reverse = False ) } else : d [ item [ 0 ] ] = { k : v for k , v in sorted ( item [ 1 ] . items ( ) , key = lambda x : ( - x [ 1 ] , x [ 0 ] ) , reverse = False ) } elif sort_by == "category" : for item in data . items ( ) : d [ item [ 0 ] ] = { k : v for k , v in sorted ( item [ 1 ] . items ( ) , key = lambda x : ( x [ 1 ] [ 1 ] , x [ 0 ] ) , reverse = False ) } elif sort_by == "alphabetical" : for x , y in data . items ( ) : d [ x ] = { k : v for k , v in sorted ( y . items ( ) ) } labels = [ list ( x [ 1 ] . keys ( ) ) for x in d . items ( ) ] values = [ [ y [ 0 ] if type ( y ) == tuple else y for y in x [ 1 ] . values ( ) ] for x in d . items ( ) ] categories = [ [ y [ 1 ] if type ( y ) == tuple else "null" for y in x [ 1 ] . values ( ) ] for x in d . items ( ) ] headers = list ( d . keys ( ) ) node_x = 0 count = 0 count2 = 0 nodes = [ ] sequence = { } for l , v , s in zip ( labels , values , categories ) : if count2 < len ( labels ) : count2 += 1 for x , y , z in zip ( l , v , s ) : nodes . append ( Node ( count , count2 , 0 , 0 , y , y , 1 , x , z ) ) count += 1 for n in nodes : if n . label in sequence . keys ( ) : sequence [ n . label ] . append ( n . index ) else : sequence [ n . label ] = [ ] sequence [ n . label ] . append ( n . index ) return [ headers , nodes , sequence ]
Takes data and creates a list containing information about the nodes for the graph.
Takes data and creates a list containing information about the nodes for the graph .
"""
    Takes data and creates a list containing information about the nodes for the graph.

    Parameters:
    data (dict): output of the read_file/read functions, a dictionary with keys the temporal data, and values a dictionary with keys of the item and values or the frequency of the item or a tuple with the frequency and the category
    sort_by (str): "frequency" or "alphabetical" or "category", defaults to "frequency"

    Returns:
    (list): A list containing information about the nodes for the graph
    """
data
sort_by