This repository contains the Java program Advertising, which aims to find a minimum spanning tree for a graph representing a city map. The program assists the Mayor's office in installing advertising terminals in a neighborhood, connecting all public places in the district with a wired network in an optimal manner.
The objectives of the program are as follows:
- Implement an abstract data type Carte based on the graph representation.
- Implement an algorithm to find a minimum spanning tree with Prim-jarnik's algorithm.
The Mayor's office wants to install advertising terminals in a neighborhood to connect all the public places within the district. The provided data includes the list of the most visited public places with corresponding streets in the neighborhood and the cost of terminal installations on each street segment.
A street is identified by a set of places, and both streets and sites are represented by their names. For example:
- "rue0" is the street name
- "a", "b" are the place names
- "4" is the installation cost
The neighborhood sites are connected to each other by forming a labeled connected graph, where nodes represent the neighborhood sites, edges represent the segments of streets connecting the sites, and edge weights represent the installation cost. The objective of Adversiting is to find a minimum spanning tree (ARMin) of the neighborhood site graph using the Prim-Jarnik algorithm. When processing edges of the same weight, the program should consider the alphanumeric order of the edge out vertices. In case of equality of weights and edge "out vertices," the alphanumeric order of the edge "in vertices" should be used.
The program should adhere to the following specifications:
- Call Syntax: The program should be executed using the appropriate Java command or through an IDE.
- Input Format: The input data should be provided to the program in a specific format as specified by the assignment.
- Output Format: The program should generate the minimum spanning tree in the prescribed format as per the assignment's requirements.
Ensure that the program retains the original call syntax, input format, and output format to achieve compatibility with other components and systems.
The call of your program should be as follows:
- The file
carte.txtspecifies a district public places map with the installation cost. - The results (a generated minimum spanning tree) have to be saved in the file
arm.txt.
The file carte.txt is composed of the following sections:
-
Public Places List (Nodes):
- Each place is defined by its name (string) on a separate line.
-
Separation Line:
- The next line contains three dashes (---) to separate the public places list from the street segments.
-
Street Segments:
- Each street segment is specified on a separate line.
- Format:
Street name : PlaceIn ; PlaceOut ; InstallationCost ; - Example:
rue0 : a ; b ; 4 ;
-
End Separator:
- Three dashes (---) indicate the end of the street segments section.
The found spanning tree has to be saved in the arm.txt file in the following format:
-
Sites List:
- One site on each line.
-
Street Segments with Corresponding Information:
- Each line corresponds to a street segment (edge) in the spanning tree.
- Format:
a) Street name: rue0 b) Sites names: a b c) A label (cost): 4
-
Separation Line:
- Three dashes (---) of separation between the segments and the total spanning tree cost.
-
Total Spanning Tree Cost:
- The spanning tree cost is displayed on the last line.
You can find the Java source code for the Adversiting program in the src directory of this repository.
To run the Adversiting program, follow these steps:
- Clone this repository to your local machine.
- Open a terminal or command prompt and navigate to the repository directory.
- Compile the Java source code:
- Run the program with the input file
carte.txtand save the output toarm.txt: - Check the
arm.txtfile to see the generated minimum spanning tree.
Feel free to modify the input data in carte.txt to test the program with different scenarios.
This repository provides the Electronic Billboards Installation Planning program (Adversiting) that helps in finding an optimal solution for installing advertising terminals in a neighborhood. You can use the program as specified in the README and explore the provided sample code to understand the implementation.