You can create a
PgqlGraphVisualization instance
as shown in the following code examples:
For Local
Databasevq = PgqlGraphVisualization(
"<db_username>",
"<db_password>",
connection={"dsn": f"{<host>}:{<port>}/{<service_name>}"},
)
For Autonomous AI Database
(Wallet/tnsnames.ora)vq = PgqlGraphVisualization(
"<db_username>",
"<db_password>",
connection={
"tns_alias": "<tns_alias_in_tnsnames.ora>",
"wallet_location": "<wallet_location>",
},
)
The following example shows how to visualize a PGQL query using
PgqlGraphVisualization against the property graph created
in
step-4.
from pypgx import setloglevel
from oraclegraph import GraphVisualization, PgqlGraphVisualization
setloglevel('ROOT', 'WARN')
vq = PgqlGraphVisualization(
"graphuser",
"<password_for_graphuser>",
connection={"dsn": f"<host_name:port>/<service_name>"},
)
query='''
SELECT * FROM GRAPH_TABLE (bank_graph_pgql
MATCH (a) -[e]-> (b)
WHERE a.ID=816
COLUMNS (a.ID AS src_ac, e.AMOUNT AS amount, b.ID AS dest_ac)
)
'''
graph_query = vq.visualize_query(query)
defaults_feature = {
"interactionActive": True,
"1stickyActive": True
}
base_styles = {
"vertex": {
"label": "${properties.ID}",
"size": 20
},
"edge": {
"label": "${properties.AMOUNT}"
}
}
rule_based_styles = [{
"stylingEnabled": True,
"component": "vertex",
"target": "vertex",
"conditions": {
"conditions": [{
"property": "BALANCE",
"operator": "<=",
"value": 5000
}],
},
"style": {
"color": "green"
},
"legendTitle": "Balance Filter",
"legendDisplayed": True
}
]
settings = {
"numberOfHops": 2,
"showLegend": True,
"defaults": defaults_feature,
"baseStyles": base_styles,
"ruleBasedStyles": rule_based_styles
}
bank_graph = GraphVisualization(data = graph_query, settings = settings)
bank_graph.height = 600
display(bank_graph)
The preceding code produces the following visualization
result: