Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

###Bugs###

Bugs

Your isRing() function doesn't check that the whole graph is a single ring. If you had a graph with two disconnected rings, it would still return true.

Your isStar() function doesn't check that the limbs are connected to the center, only that they have one outgoing edge. If you construct a graph where the center connects outwards to all other vertices, but the other vertices connect to each other in a one-way ring, it would pass your test (although this graph would be have asymmetrical one-way edges).

For both cases, you probably need to check this.matrix[row][row] != false like you do with the third case. Otherwise your falseCount will be off by one.

###Bugs###

Your isRing() function doesn't check that the whole graph is a single ring. If you had a graph with two disconnected rings, it would still return true.

Your isStar() function doesn't check that the limbs are connected to the center, only that they have one outgoing edge. If you construct a graph where the center connects outwards to all other vertices, but the other vertices connect to each other in a one-way ring, it would pass your test (although this graph would be have asymmetrical one-way edges).

For both cases, you probably need to check this.matrix[row][row] != false like you do with the third case. Otherwise your falseCount will be off by one.

Bugs

Your isRing() function doesn't check that the whole graph is a single ring. If you had a graph with two disconnected rings, it would still return true.

Your isStar() function doesn't check that the limbs are connected to the center, only that they have one outgoing edge. If you construct a graph where the center connects outwards to all other vertices, but the other vertices connect to each other in a one-way ring, it would pass your test (although this graph would be have asymmetrical one-way edges).

For both cases, you probably need to check this.matrix[row][row] != false like you do with the third case. Otherwise your falseCount will be off by one.

Source Link
JS1
  • 28.8k
  • 3
  • 41
  • 83

###Bugs###

Your isRing() function doesn't check that the whole graph is a single ring. If you had a graph with two disconnected rings, it would still return true.

Your isStar() function doesn't check that the limbs are connected to the center, only that they have one outgoing edge. If you construct a graph where the center connects outwards to all other vertices, but the other vertices connect to each other in a one-way ring, it would pass your test (although this graph would be have asymmetrical one-way edges).

For both cases, you probably need to check this.matrix[row][row] != false like you do with the third case. Otherwise your falseCount will be off by one.

lang-java

AltStyle によって変換されたページ (->オリジナル) /