mem_nfa_graph Function

public function mem_nfa_graph(graph) result(res)

Uses

    • forgex_nfa_graph_m

Arguments

Type IntentOptional Attributes Name
type(nfa_graph_t), intent(in) :: graph

Return Value integer


Source Code

   function mem_nfa_graph(graph) result(res)
      use :: forgex_nfa_graph_m
      implicit none
      type(nfa_graph_t), intent(in) :: graph
      integer :: res, sum_node, sum_tra, i, j

      res = 12 ! 3 int32

      sum_node = 0
      do i = NFA_STATE_BASE, graph%nfa_top
         sum_node = sum_node + 5*4 ! 5 int32
         sum_tra = 0
         if (.not. allocated(graph%nodes(i)%forward)) cycle

         b: do j = lbound(graph%nodes(i)%forward, dim=1), ubound(graph%nodes(i)%forward, dim=1)
            if (.not. allocated(graph%nodes(i)%forward)) cycle b
            sum_tra = sum_tra + 4*4 ! 3 int32, 1 logical
            if (allocated(graph%nodes(i)%forward(j)%c)) then
               sum_tra = sum_tra + 8*size(graph%nodes(i)%forward(j)%c)
            end if
         end do b

         sum_node = sum_node + sum_tra*2 ! forward and backward
      end do
      res = res + sum_node
      res = res + (ubound(graph%nodes, dim=1) - graph%nfa_top)*5 ! 5 int32

   end function mem_nfa_graph