1

I am applying a modified DFS and I want my python script to plot the graph that it is traversing in real time, so I can see where the search is happening.I have been finding but can't get anything specific. Is it possible to do this without me writing libraries and how if yes?

Huy Vo
  • 2,418
  • 6
  • 22
  • 43
dhrumil barot
  • 448
  • 2
  • 5
  • 17

1 Answers1

1

You should have a look at the small streamz python package. It relies on Bokeh another python library that can create dynamical plots using javascript. Have a look at this specific Bokeh example, which might already be close to what you want.

Personally I'm using Jupyter when implementing streams in python.

You are very broad in your problem description which makes it hard to give you a specific answer, but consider this minimal example, maybe this helps you to get started:

from streamz.dataframe import Random, StreamingDataFrame

params = {'freq': '2ms', 'interval': '50ms'}
source = Random(**params)

stream_df = (source * 0.5).cumsum()

sdf_params = {
    'row': stream_df.x.rolling('100ms').mean(),
    'very-smooth': stream_df.x.rolling('1000ms').mean()
}

p = StreamingDataFrame(sdf_params).plot()

I hope this helps you getting started. Consider to modify you question by providing more details and a clearer problem statement. You'll, in return, certainly get more specific answers.

NKahle
  • 142
  • 6
  • Assume that I want to apply [link](https://en.wikipedia.org/wiki/Depth-first_search#Pseudocode) and I also want to see where exactly is my script while traversing the graph.like this[link](https://en.wikipedia.org/wiki/Breadth-first_search#/media/File:Animated_BFS.gif) @NKahle – dhrumil barot Jan 02 '18 at 10:41