Skip to content

Commit

Permalink
Merge pull request #517 from yui-knk/explanation_of_Digraph
Browse files Browse the repository at this point in the history
More explanation for Digraph algorithm
  • Loading branch information
yui-knk authored Jan 21, 2025
2 parents 043c2dc + 25f344a commit 5eadda7
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
24 changes: 21 additions & 3 deletions lib/lrama/digraph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,28 @@
# frozen_string_literal: true

module Lrama
# Algorithm Digraph of https://dl.acm.org/doi/pdf/10.1145/69622.357187 (P. 625)
# Digraph Algorithm of https://dl.acm.org/doi/pdf/10.1145/69622.357187 (P. 625)
#
# @rbs generic X < Object -- Type of a member of `sets`
# @rbs generic Y < _Or -- Type of sets assigned to a member of `sets`
# Digraph is an algorithm for graph data structure.
# The algorithm efficiently traverses SCC (Strongly Connected Component) of graph
# and merges nodes attributes within the same SCC.
#
# `compute_read_sets` and `compute_follow_sets` have the same structure.
# Graph of gotos and attributes of gotos are given then compute propagated attributes for each node.
# In the case of `compute_read_sets`:
#
# * Set of gotos is nodes of graph
# * `reads_relation` is edges of graph
# * `direct_read_sets` is nodes attributes
#
# In the case of `compute_follow_sets`:
# * Set of gotos is nodes of graph
# * `includes_relation` is edges of graph
# * `read_sets` is nodes attributes
#
#
# @rbs generic X < Object -- Type of a node
# @rbs generic Y < _Or -- Type of attribute sets assigned to a node which should support merge operation (#| method)
class Digraph
# TODO: rbs-inline 0.10.0 doesn't support instance variables.
# Move these type declarations above instance variable definitions, once it's supported.
Expand Down
24 changes: 21 additions & 3 deletions sig/generated/lrama/digraph.rbs
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
# Generated from lib/lrama/digraph.rb with RBS::Inline

module Lrama
# Algorithm Digraph of https://dl.acm.org/doi/pdf/10.1145/69622.357187 (P. 625)
# Digraph Algorithm of https://dl.acm.org/doi/pdf/10.1145/69622.357187 (P. 625)
#
# @rbs generic X < Object -- Type of a member of `sets`
# @rbs generic Y < _Or -- Type of sets assigned to a member of `sets`
# Digraph is an algorithm for graph data structure.
# The algorithm efficiently traverses SCC (Strongly Connected Component) of graph
# and merges nodes attributes within the same SCC.
#
# `compute_read_sets` and `compute_follow_sets` have the same structure.
# Graph of gotos and attributes of gotos are given then compute propagated attributes for each node.
# In the case of `compute_read_sets`:
#
# * Set of gotos is nodes of graph
# * `reads_relation` is edges of graph
# * `direct_read_sets` is nodes attributes
#
# In the case of `compute_follow_sets`:
# * Set of gotos is nodes of graph
# * `includes_relation` is edges of graph
# * `read_sets` is nodes attributes
#
#
# @rbs generic X < Object -- Type of a node
# @rbs generic Y < _Or -- Type of attribute sets assigned to a node which should support merge operation (#| method)
class Digraph[X < Object, Y < _Or]
interface _Or
def |: (self) -> self
Expand Down

0 comments on commit 5eadda7

Please sign in to comment.