parser=argparse.ArgumentParser(description="Analyze a given file.")
parser.add_argument("-general",help="Show some general info on the graph",action="store_true")
parser.add_argument("-top-nodes",type=int,metavar="N",help="Show N top nodes according to degree")
parser.add_argument("-detail",type=str,choices=["defendant","victim","participant","verdict","offence","punishment","description"],help="Show details on selected category over all trials")
parser.add_argument("file",help="Path to the graph file to analyze")
args=parser.parse_args()
inputfile=args.file
print("Processing",inputfile)
withopen(inputfile)asf:
data=json.load(f)
nodes=data["nodes"]
edges=data["links"]
G=nx.MultiDiGraph()
foredgeinedges:
source=edge["source"]
target=edge["target"]
G.add_edge(source,target)
ifargs.general:
print("\nNumber of nodes:",len(nodes))
print("Number of edges:",len(edges))
print("Number of trials:",len([xforxinnodesifx['label']=="Trial"]))