Reinforz / fauton

An ecosystem of packages to work with automaton and parsers (dfa/nfa/e-nfa/regex/cfg/pda)

Home Page:http://docs.fauton.xyz

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mark final states in html generated by d3

Devorein opened this issue · comments

const { NonDeterministicFiniteAutomaton, Render } = require('fauton');
const path = require('path');

const nfa = new NonDeterministicFiniteAutomaton((_, automatonTestResult) => automatonTestResult, {
  label: 'NFA 1',
  final_states: ['D'],
  start_state: 'A',
  alphabets: ['0', '1'],
  states: ['A', 'B', 'C', 'D'],
  transitions: {
    A: ['A'],
    B: ['D', 'C'],
    D: [null, 'D'],
  },
  epsilon_transitions: {
    A: ['C'],
    C: ['B'],
    D: ['C'],
  },
});
const { graph } = nfa.generateGraphFromString('1101');
Render.graphToHtml(graph, path.join(__dirname, 'index.html'));

For a d3 html graph generated from a nfa, no final states are marked. The above code would generate the following graph
image
But no final states are marked at the leaf nodes.