<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 DSGRN Python Interface Tutorial
This notebook shows the basics of manipulating DSGRN with the python interface.
Step1:  Network
The starting point of the DSGRN analysis is a network specification file. We have a network specification file "network.txt" we will load.
Step2:  Graphviz
Many of the objects in DSGRN provide a method "graphviz" which emits a string understood by the graphviz language. In an iPython notebook we can embed these picture easily.
Step3:  ParameterGraph
Given a network, there is an associated "Parameter Graph", which is a combinatorial representation of parameter space.
Step4:  Parameter
The ParameterGraph class may be regarded as a factory which produces parameter nodes. In the DSGRN code, parameter nodes are referred to simply as "parameters" and are represented as "Parameter" objects.
Step5:  DomainGraph
Let's compute the dynamics corresponding to this parameter node. In particular, we can instruct DSGRN to create a "domaingraph" object.
Step6:  MorseDecomposition
Let's compute the partially ordered set of recurrent components (strongly connected components with an edge) of the domain graph.
Step7:  MorseGraph
The final step in our analysis is the production of an annotated Morse graph.
<ASSISTANT_TASK:>
Python Code:
import DSGRN
Explanation: DSGRN Python Interface Tutorial
This notebook shows the basics of manipulating DSGRN with the python interface.
End of explanation
network = DSGRN.Network("network.txt")
print(network)
print(network.graphviz())
Explanation: Network
The starting point of the DSGRN analysis is a network specification file. We have a network specification file "network.txt" we will load.
End of explanation
import graphviz
graph = graphviz.Source(network.graphviz())
graph
Explanation: Graphviz
Many of the objects in DSGRN provide a method "graphviz" which emits a string understood by the graphviz language. In an iPython notebook we can embed these picture easily.
End of explanation
parametergraph = DSGRN.ParameterGraph(network)
print("There are " + str(parametergraph.size()) + " nodes in the parameter graph.")
Explanation: ParameterGraph
Given a network, there is an associated "Parameter Graph", which is a combinatorial representation of parameter space.
End of explanation
parameterindex = 34892  # An integer in [0,32592)
parameter = parametergraph.parameter(parameterindex)
parameter
print(parameter)
Explanation: Parameter
The ParameterGraph class may be regarded as a factory which produces parameter nodes. In the DSGRN code, parameter nodes are referred to simply as "parameters" and are represented as "Parameter" objects.
End of explanation
domaingraph = DSGRN.DomainGraph(parameter)
domaingraph
graphviz.Source(domaingraph.graphviz())
print(domaingraph.coordinates(5)) # ... I wonder what region in phase space domain 5 corresponds to.
Explanation: DomainGraph
Let's compute the dynamics corresponding to this parameter node. In particular, we can instruct DSGRN to create a "domaingraph" object.
End of explanation
morsedecomposition = DSGRN.MorseDecomposition(domaingraph.digraph())
graphviz.Source(morsedecomposition.graphviz())
Explanation: MorseDecomposition
Let's compute the partially ordered set of recurrent components (strongly connected components with an edge) of the domain graph.
End of explanation
morsegraph = DSGRN.MorseGraph()
morsegraph.assign(domaingraph, morsedecomposition)
morsegraph
print(morsegraph)
graphviz.Source(morsegraph.graphviz())
Explanation: MorseGraph
The final step in our analysis is the production of an annotated Morse graph.
End of explanation
<END_TASK>