Overview
This prompt aims to guide programmers in enhancing a C++ function to support multiple algorithms’ outputs. Developers working with graph algorithms will benefit from this clear and structured approach to code modification.
Prompt Overview
Purpose: The function `LogEdgeInfo()` is designed to log edge information based on selected algorithms.
Audience: This information is intended for developers working with graph algorithms in C++.
Distinctive Feature: The function currently supports logging for the FloydWarshall algorithm and needs enhancement for BellmanFord.
Outcome: The updated function will log outputs from both algorithms when their respective flags are true.
Quick Specs
- Media: Text
- Use case: Generation
- Industry: Development Tools & DevOps, Machine Learning & Data Science, Productivity & Workflow
- Techniques: Decomposition, Role/Persona Prompting, Structured Output
- Models: Claude 3.5 Sonnet, Gemini 2.0 Flash, GPT-4o, Llama 3.1 70B
- Estimated time: 5-10 minutes
- Skill level: Beginner
Variables to Fill
No inputs required — just copy and use the prompt.
Example Variables Block
No example values needed for this prompt.
The Prompt
You are given a C++ function `void LogEdgeInfo()` that currently outputs information using the FloydWarshall algorithm when the flag `UseFloydWarshall` is set to true. However, when `UseBellmanFord` is set to true, the function does not generate any output in the journal.
Your task is to modify or enhance the `LogEdgeInfo()` function so that it also outputs relevant information from the BellmanFord algorithm when `UseBellmanFord` is true, just as it currently does for FloydWarshall.
Ensure that:
– The output generated by `LogEdgeInfo()` includes `PrintFormat()` results from the BellmanFord algorithm when `UseBellmanFord` is true.
– The existing FloydWarshall output remains intact and is included only if `UseFloydWarshall` is true.
– If both `UseFloydWarshall` and `UseBellmanFord` are true, output from both algorithms should be included appropriately.
– The output format and style are consistent and clear in the journal or log.
# Steps
1. Identify where `LogEdgeInfo()` currently checks for `UseFloydWarshall` and outputs its `PrintFormat()`.
2. Integrate a similar check for `UseBellmanFord`.
3. Add the code required to output the BellmanFord algorithm information in the same manner.
4. Verify that when `UseBellmanFord = true`, the BellmanFord output appears, and when false, it does not.
# Output Format
Return or provide the updated source code snippet of the `LogEdgeInfo()` function reflecting the described changes. Ensure the code is clean, readable, and well-commented if necessary.
# Notes
– If the BellmanFord output requires calling a specific `PrintFormat()` method or similar, include that call correctly.
– If any other dependent components or flags are required for BellmanFord output, account for them as well.
Screenshot Examples
How to Use This Prompt
- Copy the prompt provided above.
- Open your C++ project file containing `LogEdgeInfo()` function.
- Locate the section checking `UseFloydWarshall` in the function.
- Add a similar check for `UseBellmanFord` to output its information.
- Ensure both outputs are formatted consistently in the journal.
- Test the function with both flags to verify correct outputs.
Tips for Best Results
- Check Flags: Ensure that both `UseFloydWarshall` and `UseBellmanFord` flags are checked in the `LogEdgeInfo()` function.
- Integrate BellmanFord Output: Add a conditional statement to call the `PrintFormat()` method for the BellmanFord algorithm when its flag is true.
- Maintain Existing Functionality: Keep the existing output for FloydWarshall intact, ensuring both outputs can coexist if both flags are true.
- Test Outputs: Verify that the outputs for both algorithms appear correctly in the journal based on the respective flags’ states.
FAQ
- What does the LogEdgeInfo() function do?
It outputs information using the FloydWarshall algorithm based on specific flags. - How can LogEdgeInfo() include BellmanFord outputs?
By adding a check for UseBellmanFord and calling the appropriate PrintFormat() method. - What happens if both UseFloydWarshall and UseBellmanFord are true?
The function will output results from both algorithms in a clear format. - Why is it important to maintain output format consistency?
Consistency ensures clarity and readability in the journal or log for users.
Compliance and Best Practices
- Best Practice: Review AI output for accuracy and relevance before use.
- Privacy: Avoid sharing personal, financial, or confidential data in prompts.
- Platform Policy: Your use of AI tools must comply with their terms and your local laws.
Revision History
- Version 1.0 (February 2026): Initial release.


