The SearchEngine
class is a Java program designed to manage a web graph, allowing users to perform various operations such as adding/removing pages, adding/removing links between pages, printing the graph, and searching for pages based on keywords. The program provides an interactive command-line interface (CLI) for user interaction.
- Add a new page to the graph (AP): Users can add a new page to the web graph by providing a URL and associated keywords.
- Remove a page from the graph (RP): Users can remove an existing page from the web graph by specifying its URL.
- Add a link between pages in the graph (AL): Users can establish a hyperlink between two existing pages in the web graph.
- Remove a link between pages in the graph (RL): Users can remove an existing hyperlink between two pages in the web graph.
- Print the graph (P): Users can print the entire web graph, with options to sort based on index, URL, or rank.
- Search for pages with a keyword (S): Users can search for pages containing a specific keyword and view the search results ranked by page rank.
- Quit (Q): Users can exit the program.
The program relies on two text files for initializing the web graph:
- pages.txt: Contains a list of URLs and associated keywords for web pages.
- links.txt: Specifies the hyperlinks between pages in the web graph.
- Ensure that the
pages.txt
andlinks.txt
files are present in the appropriate directory specified in theSearchEngine
class. - Compile and run the
SearchEngine
class in a Java environment. - Follow the on-screen prompts to interact with the program:
- Select options from the menu by entering the corresponding option code.
- Provide necessary inputs such as URLs, keywords, or source/destination URLs as requested by the program.
- Upon selecting the Quit (Q) option, the program will terminate.
- The program incorporates error handling mechanisms to manage illegal inputs and file-related errors. Users will receive appropriate error messages in case of invalid inputs or file access issues.
- Illegal entries or invalid operations will prompt the user to try again.
The program is written in Java and does not rely on external libraries or frameworks beyond the standard Java Development Kit (JDK).