Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visualizing tools for the circuits #23

Closed
wenzhe-li opened this issue Jul 10, 2020 · 2 comments
Closed

Visualizing tools for the circuits #23

wenzhe-li opened this issue Jul 10, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@wenzhe-li
Copy link

I found it useful to visualize the circuit in programming. Below is a naive print function for probabilistic circuits, but we can do better with julia graph visualization tools : )

function print_circuit_dfs(node::ProbΔNode, tab=0, weight=0)
  for i = 1 : tab
    print("> ")
  end
  if node isa ProbLiteral
    print("Literal ", lit2var(literal(node)), " ", positive(node), " ")
    if weight > 0
      print("(", weight, ")")
    end
    print("\n")
  elseif node isa Prob⋀
    print("AND ")
    if weight > 0
      print("(", weight, ")")
    end
    print("\n")
    for i in 1 : length(node.children)
      print_circuit_dfs(node.children[i], tab + 1)
    end
  elseif node isa Prob⋁
    print("OR ")
    if weight > 0
      print("(", weight, ")")
    end
    print("\n")
    p_thetas = [exp(node.log_thetas[i]) for i in 1 : length(node.children)]
    for i in 1 : length(node.children)
      print_circuit_dfs(node.children[i], tab + 1, p_thetas[i])
    end
  else
    println("ERROR ", node)
  end
end
@guyvdbroeck
Copy link
Member

Would be nice to use https://github.com/JuliaGraphs/GraphPlot.jl for this.

@guyvdbroeck guyvdbroeck added the enhancement New feature or request label Jul 11, 2020
@khosravipasha
Copy link
Collaborator

GraphPlot does not support Tree of DAG layout it seems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants