Skip to content

Pygesux/GalaxyGroveTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GalaxyGroveTest

When executing the program ensure that the working directory is the project root.

Test

  • Write a command line program in C++
  • Do not use any additional libraries (std is fine of course)
  • The program does the following:
  • Read a file from disk like the one attached and generate a graph with nodes and edges as described in the file. "A<>B" means a bidirectional edge, "A->B" means a unidirectional edge.
  • Find and remove any nodes that have exactly three incoming edges (so edges that are either directed at the node or bidirectional).
  • Print all the remaining edges, similar to how the input file looks (no need to write it to a file, std::cout is fine).

Input Format

  • One edge per line.
  • Supported forms:
    • A->B (directed from A to B)
    • A<>B (bidirectional between A and B)
    • A<-B (equivalent to B->A)

Behavior

  • Incoming edge count:
    • Directed A->B counts as one incoming edge to B.
    • Bidirectional A<>B counts as one incoming edge for both A and B.
  • Removal:
    • Nodes with exactly three incoming edges are removed.
    • All incident edges to removed nodes are deleted.
  • Output:
    • Remaining edges are printed to stdout, one per line, using the same notation (-> or <>).
    • Each edge appears once (e.g., A<>B printed in canonical order).

Design Overview

  • Graph stores nodes in a hash map keyed by node label.
  • Each node tracks inbound and outbound connections.
  • Removal is done in two phases:
    1. Collect nodes with exactly three inbound edges.
    2. Remove them and clear them from other nodes.
  • Printing ensures no duplicate edge output:
    • <> edges printed once.
    • -> edges printed once per direction.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published