original_docstring: 
      Do GraphViz visualization of a DFG graph
  
      Parameters
      -----------
      activities_count
          Count of attributes in the log (may include attributes that are not in the DFG graph)
      dfg
          DFG graph
      image_format
          GraphViz should be represented in this format
      measure
          Describes which measure is assigned to edges in direcly follows graph (frequency/performance)
      max_no_of_edges_in_diagram
          Maximum number of edges in the diagram allowed for visualization
      start_activities
          Start activities of the log
      end_activities
          End activities of the log
      soj_time
          For each activity, the sojourn time in the log
      stat_locale
          Dict to locale the stat strings
      
      Returns
      -----------
      viz
          Digraph object
      
docstring: Do GraphViz visualization of a DFG graph
  Parameters
  
  activities_count
  Count of attributes in the log (may include attributes that are not in the DFG graph)
  dfg
  DFG graph
  image_format
  GraphViz should be represented in this format
  measure
  Describes which measure is assigned to edges in direcly follows graph (frequency/performance)
  max_no_of_edges_in_diagram
  Maximum number of edges in the diagram allowed for visualization
  start_activities
  Start activities of the log
  end_activities
  End activities of the log
  soj_time
  For each activity, the sojourn time in the log
  stat_locale
  Dict to locale the stat strings
  
  Returns
  
  viz
  Digraph object
docstring_tokens: Do GraphViz visualization of a DFG graph Parameters activities_count Count of attributes in the log ( may include attributes that are not in the DFG graph ) dfg DFG graph image_format GraphViz should be represented in this format measure Describes which measure is assigned to edges in direcly follows graph ( frequency / performance ) max_no_of_edges_in_diagram Maximum number of edges in the diagram allowed for visualization start_activities Start activities of the log end_activities End activities of the log soj_time For each activity the sojourn time in the log stat_locale Dict to locale the stat strings Returns viz Digraph object
code: def graphviz_visualization(activities_count, dfg, image_format="png", measure="frequency",
                             max_no_of_edges_in_diagram=100000, start_activities=None, 
                             end_activities=None, soj_time=None, font_size="12", 
                             bgcolor="transparent", stat_locale: dict = None):
      """
      Do GraphViz visualization of a DFG graph
  
      Parameters
      -----------
      activities_count
          Count of attributes in the log (may include attributes that are not in the DFG graph)
      dfg
          DFG graph
      image_format
          GraphViz should be represented in this format
      measure
          Describes which measure is assigned to edges in direcly follows graph (frequency/performance)
      max_no_of_edges_in_diagram
          Maximum number of edges in the diagram allowed for visualization
      start_activities
          Start activities of the log
      end_activities
          End activities of the log
      soj_time
          For each activity, the sojourn time in the log
      stat_locale
          Dict to locale the stat strings
      
      Returns
      -----------
      viz
          Digraph object
      """
      if start_activities is None:
          start_activities = {}
      if end_activities is None:
          end_activities = {}
      if stat_locale is None:
          stat_locale = {}
  
      filename = tempfile.NamedTemporaryFile(suffix='.gv')
      viz = Digraph("", filename=filename.name, engine='dot', graph_attr={'bgcolor': bgcolor})
  
      # first, remove edges in diagram that exceeds the maximum number of edges in the diagram
      dfg_key_value_list = []
      for edge in dfg:
          dfg_key_value_list.append([edge, dfg[edge]])
      # more fine grained sorting to avoid that edges that are below the threshold are
      # undeterministically removed
      dfg_key_value_list = sorted(dfg_key_value_list, key=lambda x: (x[1], x[0][0], x[0][1]), reverse=True)
      dfg_key_value_list = dfg_key_value_list[0:min(len(dfg_key_value_list), max_no_of_edges_in_diagram)]
      dfg_allowed_keys = [x[0] for x in dfg_key_value_list]
      dfg_keys = list(dfg.keys())
      for edge in dfg_keys:
          if edge not in dfg_allowed_keys:
              del dfg[edge]
  
      # calculate edges penwidth
      penwidth = assign_penwidth_edges(dfg)
      activities_in_dfg = set()
      activities_count_int = copy(activities_count)
  
      for edge in dfg:
          activities_in_dfg.add(edge[0])
          activities_in_dfg.add(edge[1])
  
      # assign attributes color
      activities_color = get_activities_color(activities_count_int)
  
      # represent nodes
      viz.attr('node', shape='box')
  
      if len(activities_in_dfg) == 0:
          activities_to_include = sorted(list(set(activities_count_int)))
      else:
          # take unique elements as a list not as a set (in this way, nodes are added in the same order to the graph)
          activities_to_include = sorted(list(set(activities_in_dfg)))
  
      activities_map = {}
  
      for act in activities_to_include:
          if "frequency" in measure and act in activities_count_int:
              viz.node(str(hash(act)), act + " (" + str(activities_count_int[act]) + ")", style='filled',
                       fillcolor=activities_color[act], fontsize=font_size)
              activities_map[act] = str(hash(act))
          else:
              stat_string = human_readable_stat(soj_time[act], stat_locale)
              viz.node(str(hash(act)), act + f" ({stat_string})", fontsize=font_size)
              activities_map[act] = str(hash(act))
  
      # make edges addition always in the same order
      dfg_edges = sorted(list(dfg.keys()))
  
      # represent edges
      for edge in dfg_edges:
          if "frequency" in measure:
              label = str(dfg[edge])
          else:
              label = human_readable_stat(dfg[edge], stat_locale)
          viz.edge(str(hash(edge[0])), str(hash(edge[1])), label=label, penwidth=str(penwidth[edge]), fontsize=font_size)
  
      start_activities_to_include = [act for act in start_activities if act in activities_map]
      end_activities_to_include = [act for act in end_activities if act in activities_map]
  
      if start_activities_to_include:
          viz.node("@@startnode", "<&#9679;>", shape='circle', fontsize="34")
          for act in start_activities_to_include:
              label = str(start_activities[act]) if isinstance(start_activities, dict) else ""
              viz.edge("@@startnode", activities_map[act], label=label, fontsize=font_size)
  
      if end_activities_to_include:
          # <&#9632;>
          viz.node("@@endnode", "<&#9632;>", shape='doublecircle', fontsize="32")
          for act in end_activities_to_include:
              label = str(end_activities[act]) if isinstance(end_activities, dict) else ""
              viz.edge(activities_map[act], "@@endnode", label=label, fontsize=font_size)
  
      viz.attr(overlap='false')
  
      viz.format = image_format
  
      return viz
code_tokens: def graphviz_visualization ( activities_count , dfg , image_format = "png" , measure = "frequency" , max_no_of_edges_in_diagram = 100000 , start_activities = None , end_activities = None , soj_time = None , font_size = "12" , bgcolor = "transparent" , stat_locale : dict = None ) : if start_activities is None : start_activities = { } if end_activities is None : end_activities = { } if stat_locale is None : stat_locale = { } filename = tempfile . NamedTemporaryFile ( suffix = '.gv' ) viz = Digraph ( "" , filename = filename . name , engine = 'dot' , graph_attr = { 'bgcolor' : bgcolor } ) dfg_key_value_list = [ ] for edge in dfg : dfg_key_value_list . append ( [ edge , dfg [ edge ] ] ) dfg_key_value_list = sorted ( dfg_key_value_list , key = lambda x : ( x [ 1 ] , x [ 0 ] [ 0 ] , x [ 0 ] [ 1 ] ) , reverse = True ) dfg_key_value_list = dfg_key_value_list [ 0 : min ( len ( dfg_key_value_list ) , max_no_of_edges_in_diagram ) ] dfg_allowed_keys = [ x [ 0 ] for x in dfg_key_value_list ] dfg_keys = list ( dfg . keys ( ) ) for edge in dfg_keys : if edge not in dfg_allowed_keys : del dfg [ edge ] penwidth = assign_penwidth_edges ( dfg ) activities_in_dfg = set ( ) activities_count_int = copy ( activities_count ) for edge in dfg : activities_in_dfg . add ( edge [ 0 ] ) activities_in_dfg . add ( edge [ 1 ] ) activities_color = get_activities_color ( activities_count_int ) viz . attr ( 'node' , shape = 'box' ) if len ( activities_in_dfg ) == 0 : activities_to_include = sorted ( list ( set ( activities_count_int ) ) ) else : activities_to_include = sorted ( list ( set ( activities_in_dfg ) ) ) activities_map = { } for act in activities_to_include : if "frequency" in measure and act in activities_count_int : viz . node ( str ( hash ( act ) ) , act + " (" + str ( activities_count_int [ act ] ) + ")" , style = 'filled' , fillcolor = activities_color [ act ] , fontsize = font_size ) activities_map [ act ] = str ( hash ( act ) ) else : stat_string = human_readable_stat ( soj_time [ act ] , stat_locale ) viz . node ( str ( hash ( act ) ) , act + f" ({stat_string})" , fontsize = font_size ) activities_map [ act ] = str ( hash ( act ) ) dfg_edges = sorted ( list ( dfg . keys ( ) ) ) for edge in dfg_edges : if "frequency" in measure : label = str ( dfg [ edge ] ) else : label = human_readable_stat ( dfg [ edge ] , stat_locale ) viz . edge ( str ( hash ( edge [ 0 ] ) ) , str ( hash ( edge [ 1 ] ) ) , label = label , penwidth = str ( penwidth [ edge ] ) , fontsize = font_size ) start_activities_to_include = [ act for act in start_activities if act in activities_map ] end_activities_to_include = [ act for act in end_activities if act in activities_map ] if start_activities_to_include : viz . node ( "@@startnode" , "<&#9679;>" , shape = 'circle' , fontsize = "34" ) for act in start_activities_to_include : label = str ( start_activities [ act ] ) if isinstance ( start_activities , dict ) else "" viz . edge ( "@@startnode" , activities_map [ act ] , label = label , fontsize = font_size ) if end_activities_to_include : viz . node ( "@@endnode" , "<&#9632;>" , shape = 'doublecircle' , fontsize = "32" ) for act in end_activities_to_include : label = str ( end_activities [ act ] ) if isinstance ( end_activities , dict ) else "" viz . edge ( activities_map [ act ] , "@@endnode" , label = label , fontsize = font_size ) viz . attr ( overlap = 'false' ) viz . format = image_format return viz
short_docstring: Do GraphViz visualization of a DFG graph
  Parameters
short_docstring_tokens: Do GraphViz visualization of a DFG graph Parameters
comment: """
      Do GraphViz visualization of a DFG graph
  
      Parameters
      -----------
      activities_count
          Count of attributes in the log (may include attributes that are not in the DFG graph)
      dfg
          DFG graph
      image_format
          GraphViz should be represented in this format
      measure
          Describes which measure is assigned to edges in direcly follows graph (frequency/performance)
      max_no_of_edges_in_diagram
          Maximum number of edges in the diagram allowed for visualization
      start_activities
          Start activities of the log
      end_activities
          End activities of the log
      soj_time
          For each activity, the sojourn time in the log
      stat_locale
          Dict to locale the stat strings
      
      Returns
      -----------
      viz
          Digraph object
      """$SEP$# first, remove edges in diagram that exceeds the maximum number of edges in the diagram$SEP$# more fine grained sorting to avoid that edges that are below the threshold are$SEP$# undeterministically removed$SEP$# calculate edges penwidth$SEP$# assign attributes color$SEP$# represent nodes$SEP$# take unique elements as a list not as a set (in this way, nodes are added in the same order to the graph)$SEP$# make edges addition always in the same order$SEP$# represent edges$SEP$# <&#9632;>