Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add test for vertices and edge count in pgraph #682

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jhu960213
Copy link

Added a test for vertices and edge count in pgraph.

Copy link
Owner

@purpleidea purpleidea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the patch! As I hear that you're learning golang, I decided to nit a few things to help you practice your rebasing. Let me know if it makes sense or if you have any questions.

Thanks!


// populate edges
var edges [5]Edge
for x := 0; x < len(edges); x++ {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can re-use i as a counter variable here and below...

// populate edges
var edges [5]Edge
for x := 0; x < len(edges); x++ {
var name string = "e" + strconv.Itoa(x+1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name := ...


// add edges to the vertices
for a := 0; a < len(vertices); a++ {
var b int = a + 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

b := a + 1

// add edges to the vertices
for a := 0; a < len(vertices); a++ {
var b int = a + 1
if a <= len(vertices)-2 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subtle: -2's don't usually appear in code as much as -1's. Since we're a zero-based language, it's expected to see a -1 here and there... But you're using the -2 off of the first of the two elements... So it raises an eyebrow... So probably best to use -1 and compare it to b instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants