lib.notebook.getMRF
- pyagrum.lib.notebook.getMRF(mrf, view=None, size=None, nodeColor=None, factorColor=None, edgeWidth=None, edgeColor=None, cmapNode=None, cmapEdge=None)
get an HTML string for a Markov random field
- Parameters:
mrf (
pyagrum.MarkovRandomField) – the Markov random fieldview (
str) – ‘graph’ | ‘factorgraph’ | None (default)size (
str) – size (for graphviz) of the rendered graphnodeColor (
dict[str,float]) – a nodeMap of values (between 0 and 1) to be shown as color of nodes (with special colors for 0 and 1)factorColor (
dict[str,float]) – a function returning a value (beeween 0 and 1) to be shown as a color of factor. (used when view=’factorgraph’)edgeWidth (
dict[tuple[str,str],float]) – a edgeMap of values to be shown as width of edges (used when view=’graph’)edgeColor (
dict[tuple[str,str],float]) – a edgeMap of values (between 0 and 1) to be shown as color of edges (used when view=’graph’)cmapNode (
matplotlib.ColorMap) – color map to show the colors (if cmapEdge is None, cmapNode is used for edges)cmapEdge (
matplotlib.ColorMap) – color map to show the edge color if distinction is needed
- Return type:
str- Returns:
the graph
Example
import pyagrum as gum
import pyagrum.lib.notebook as gnb
mrf = gum.fastMRF("A--B--C;C--D")
html = gnb.getMRF(mrf, view="factorgraph")
html.startswith("<svg")
# True