mem_dfa_graph Function

public function mem_dfa_graph(graph) result(res)

Uses

    • forgex_lazy_dfa_graph_m

Arguments

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

Return Value integer


Source Code

   function mem_dfa_graph(graph) result(res)
      use :: forgex_lazy_dfa_graph_m
      implicit none
      type(dfa_graph_t), intent(in) :: graph
      integer :: res, sum_node, sum_tra, i, j

      res = 16 ! 4 int32

      sum_node = 0
      do i = 1, graph%dfa_top-1
         sum_node = sum_node + 6 * 4 ! 3 int32, 3 logical
         if (allocated(graph%nodes(i)%nfa_set%vec)) then
            sum_node = sum_node + size(graph%nodes(i)%nfa_set%vec)*4 ! logical vector
         end if

         sum_tra = 0
         inner: do j = 1, graph%nodes(i)%get_tra_top()
            sum_tra = sum_tra + 8 + 4*2 ! segment + 2 int32
            if (.not. allocated(graph%nodes(i)%transition)) cycle inner
            if ( allocated(graph%nodes(i)%transition(j)%nfa_set%vec)) then
               sum_tra = sum_tra + size(graph%nodes(i)%transition(j)%nfa_set%vec)*4
            end if
         end do inner
         sum_node = sum_node + sum_tra
      end do
      res = res + sum_node
      res = res + (ubound(graph%nodes, dim=1) - graph%dfa_top)*6*4 ! 3 int32, 3 logical
   end function mem_dfa_graph