In computer science, a graph-structured stack (GSS) is a directed acyclic graph where each directed path represents a stack. The graph-structured stack is an essential part of Tomita's algorithm, where it replaces the usual stack of a pushdown automaton. This allows the algorithm to encode the nondeterministic choices in parsing an ambiguous grammar, sometimes with greater efficiency.

In the following diagram, there are four stacks: {7,3,1,0}, {7,4,1,0}, {7,5,2,0}, and {8,6,2,0}.

Graph-structured_stack_-_Borneq.png

Another way to simulate nondeterminism would be to duplicate the stack as needed. The duplication would be less efficient since vertices would not be shared. For this example, 16 vertices would be needed instead of 9.

Stacks_-_Borneq.dot.png

Operations

edit
GSSnode* GSS::add(GSSnode* prev, int elem)
{
	int prevlevel = prev->level;
	assert(levels.size() >= prevlevel + 1);
	int level = prevlevel + 1;
	if (levels.size() == level)
	{
		levels.resize(level + 1);
	}
	GSSnode* node = findElemAtLevel(level, elem);
	if (node == nullptr)
	{
		node = new GSSnode();
		node->elem = elem;
		node->level = level;		
		levels[level].push_back(node);
	}
	node->add(prev);
	return node;
}
void GSS::remove(GSSnode* node)
{
	if (levels.size() > node->level + 1)
		if (findPrevAtLevel(node->level + 1, node)) throw Exception("Can remove only from top.");
	for (int i = 0; i < levels[node->level].size(); i++)
		if (levels[node->level][i] == node)
		{
			levels[node->level].erase(levels[node->level].begin() + i);
			break;
		}
	delete node;
}

References

edit
  • Masaru Tomita. Graph-Structured Stack And Natural Language Parsing. Annual Meeting of the Association of Computational Linguistics, 1988. [1]
  • Elizabeth Scott, Adrian Johnstone GLL Parsing gll.pdf

📚 Artikel Terkait di Wikipedia

List of data structures

graph-based data structures are used in computer science and related fields: Graph Adjacency list Adjacency matrix Graph-structured stack Scene graph

List of graph theory topics

Bivariegated graph Cage (graph theory) Cayley graph Circle graph Clique graph Cograph Common graph Complement of a graph Complete graph Cubic graph Cycle graph De

GSS

programming interface for programs to access security services Graph Style Sheets Graph-structured stack Galileo Sensor Station, in satellite navigation Croatian

Stack (abstract data type)

with a stack of physical objects, this structure makes it easy to take an item off the top of the stack, but accessing a datum deeper in the stack may require

The Graph

The Graph provides a unified layer for accessing blockchain data through: Subgraphs: Custom APIs that define how blockchain data is structured, indexed

Graph neural network

every other node, one would need to stack a number of MPNN layers equal to the graph diameter. However, stacking many MPNN layers may cause issues such

Semantic Web Stack

semi-structured documents into a "web of data". The Semantic Web stack builds on the W3C's Resource Description Framework (RDF). The Semantic Web Stack is

Top-down parsing

may use a Graph-structured stack in addition to the aforementioned curtailment in order to accommodate left recursion by 'merging' stacks with common