from TRIAD.CacheTriad import TriadFramework
triad=TriadFramework('_SYSTEM', 'SYS', 1)
flatten = lambda l: [item for sublist in l for item in sublist]
triad.get(what='HyperNodes', env=55, str='Acme%')
part_hbs=triad.head(objectID='55||1032||110||3').get_hyperedges()
part_hbs
[triad.tail(objectID=hb).get_hypernodes(True) for hb in part_hbs]
[triad.tail(objectID=hb).get_hypernodes(False) for hb in part_hbs]
part_shared_has=[triad.tail(objectID=hb).get_hypernodes(False)[0] for hb in part_hbs]
part_shared_has
cat_hbs=[triad.head(objectID=ha).get_hyperedges(False) for ha in part_shared_has]
cat_hbs = [flatten(cat_hbs)[pos] for pos in [1,3,4]]
cat_hbs
[triad.tail(objectID=hb).get_hypernodes(True) for hb in cat_hbs]
flatten([triad.tail(objectID=hb).get_hypernodes(False) for hb in cat_hbs])
cat_shared_has=[triad.tail(objectID=hb).get_hypernodes(False)[0] for hb in cat_hbs]
cat_shared_has
sup_hbs=[triad.head(objectID=ha).get_hyperedges(False) for ha in cat_shared_has]
sup_hbs=[flatten(sup_hbs)[pos] for pos in [0,20]]
sup_hbs
[triad.tail(objectID=hb).get_hypernodes(True) for hb in sup_hbs]
sqlstr = "select ID as KEY, nodeReference->nodeValue as NAM, nodeAbbr as ABBR from TRIADB.NodeTail where ID IN "
filterstr = "('55||1032||20||3', '55||1032||20||4')"
hbonds = triad.sqlview.query_display(sqlstr+filterstr)
hbonds
sqlstr = "select ID as KEY, nodeReference->nodeValue as NAM, nodeAbbr as ABBR from TRIADB.NodeHead where ID IN "
filterstr = "('55||1032||100||3', '55||1032||110||3', '55||1032||120||1', '55||1032||130||3', '55||1032||140||2', '55||1032||100||4', '55||1032||120||3', '55||1032||140||3')"
hatoms = triad.sqlview.query_display(sqlstr+filterstr)
hatoms
hlinks1 = triad.get(what='HyperLinks', from_id='55||1032||20||3', labelA=3, labelB=4, direction='out')
hlinks2 = triad.get(what='HyperLinks', from_id='55||1032||20||4', labelA=3, labelB=4, direction='out')
import pandas as pd
hlinksout = pd.concat([hlinks1, hlinks2])
hlinksout
hlinks1 = triad.get(what='HyperLinks', from_id='55||1032||20||3', labelA=3, labelB=4, direction='in')
hlinks2 = triad.get(what='HyperLinks', from_id='55||1032||20||4', labelA=3, labelB=4, direction='in')
import pandas as pd
hlinksin = pd.concat([hlinks1, hlinks2])
hlinksin
triad.add(what='Hyper-NetworkX',
net_type='HyperBond-HyperAtom HyperGraph', net_name='Acme Widget Washer', net_short='AWW', net_path="", net_links='bidirectional',
hedges_df=hbonds, hedges_type='HE',
hnodes_df=hatoms, hnodes_type='HN',
hlinks_dfout=hlinksout, hlinks_dfin=hlinksin)
triad.add(what='Hyper-Graphviz', ekey='link_nam', nkey='nam', glayout='neato', edisplay='direct').draw()
triad.add(what='Hyper-Graphviz', ekey='link_abbr', nkey='nam', glayout='neato', edisplay='both').draw()