I'm trying to make a Bayesian Belief Network, so that I can use it to perform Sentiment Analysis on text. I was wondering which data structure should I use for coding it in Python? A link list? Any suggestions?
Guido wrote an essay on implementing graphs in Python using dictionaries. He gives the following example:
Few programming languages provide direct support for graphs as a data type, and Python is no exception. However, graphs are easily built out of lists and dictionaries. For instance, here's a simple graph (I can't use drawings in these columns, so I write down the graph's arcs):
A -> B A -> C B -> C B -> D C -> D D -> C E -> F F -> C
This graph has six nodes (A-F) and eight arcs. It can be represented by the following Python data structure:
graph = {'A': ['B', 'C'], 'B': ['C', 'D'], 'C': ['D'], 'D': ['C'], 'E': ['F'], 'F': ['C']}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments