import os.path
from TRIAD.CacheTriad import TriadFramework
triad=TriadFramework('_SYSTEM', 'SYS', 1)
# Path relative to the starting folder of Jupyter
path = os.path.join(os.path.realpath('..'), 'Data/Models')
# Get JSON filename from a tk pop-up GUI
fullpathname=triad.get(what='Filenames', fullpath=path, window_title='Select Data Model', extension='json')
# Load Data Model and create the Hyper-NetworkX in Memory
triad.load(what='Data Model', frm='HyperNetworkX File', jsonfile=fullpathname)
# Notice1:
# Links of NetworkX read from JSON file are unidirectional, we define one pair of edges, from HE nodes to HN nodes ONLY and 'net_links'='unidirectional'
# But when we pass NetworkX to the framework, the TRIADB database framework automatically turns unidirectional edges to bidirectional
# And when we save NetworkX back to JSON file both pair of edges are written. It is the 'net_links' attribute that is set to 'bidirectional'
# Notice2:
# The "vtype" attribute of each node must be any of the following data types that are currently supported in TRIADB FRAMEWORK
# Text : TXT (Short passages of text in any language)
# Word : WRD (Words or small phrases up to 128 characters long)
# Real : REA (Number)
# Integer : INT (Number)
# TimeStamp : TS (Date and Time)
# Code : COD (Any non-readable string up to 128 characters long)
# URL, PATH : LNK (URL address, or PATH up to 2048 characters long)
# Binary : RAW (Binary sequence up 1048487 bytes in size)
# Categorical : ENUM (Enumerated string up to 128 characters long)
triad.hnetx.draw(graph_layout='pydot',
graph_axis='on', graph_title='Hypergraph Network with graphviz-dot', graph_width=28, graph_height=14,
nattribute='nam', hnode_size=3000, hedge_size=3000, elabels_size=11, eattribute='link_nam')
triad.hnetx.draw(graph_layout='graphviz',
graph_axis='on', graph_title='Hypergraph Network with graphviz-dot', graph_width=36, graph_height=16,
nattribute='nam', hnode_size=4000, hedge_size=4000, elabels_size=14, eattribute='link_nam')
triad.add(what='Data Model', frm='HyperNetworkX')
triad.get(what='DME')
hedf = triad.get(what='DME', sys=1111, con=10).iloc[1:]
hedf
hndf = triad.get(what='DME', sys=1111, con=20).iloc[1:]
hndf
hldfout=triad.get(what='HL', direction='out', from_sys=1111, labelA=3, labelB=4)
hldfout
hldfin=triad.get(what='HL', direction='in', from_sys=1111, labelA=3, labelB=4)
hldfin
triad.add(what='Hyper-NetworkX',
net_type='Data Model Hypergraph', net_name='Supplier-Part-Catalogue', net_short='SPC', net_path=path, net_links='bidirectional',
hedges_df =hedf, hedges_type='HE',
hnodes_df =hndf, hnodes_type='HN',
hlinks_dfout=hldfout, hlinks_dfin=hldfin)
| ewidth=2, |eweight=1, |ecolor='blue', |edisplay='direct', |ekey='link_abbr', |nkey=None, |nxkey=None,
| glayout='neato', |goverlap='scalexy', |gsep='+20', |gnodesep=1, |gsplines='curved',
| hncolor='brown1', |hnshape='oval', |hnwidth=0.5, |hnheight=0.5, |hnfontsize=14,
| hecolor='lightgreen', |heshape='doubleoctagon', |hewidth=0.5, |heheight=0.5, |hefontsize=14
triad.add_hgraphviz(edisplay='both', glayout='neato', nkey='nam', nxkey='abbr')
triad.hgraphviz.draw()