Skip to content

Conversation

Aarebecca
Copy link
Contributor

Original PR: #7319

rubbishmaker and others added 2 commits August 18, 2025 20:06
* feat: expose methods to determine whether there are nodes, edges, and combo to graph

* feat: unit

* docs: add docs

---------

Co-authored-by: ouxiaofeng.utlf <[email protected]>
Co-authored-by: hustcc <[email protected]>
Co-authored-by: Aaron <[email protected]>
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @Aarebecca, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces three new API methods (hasNode, hasEdge, hasCombo) to the Graph class, allowing users to efficiently check for the existence of specific nodes, edges, or combos within the graph. This enhances the graph manipulation capabilities by providing direct methods for existence checks, reducing the need for manual iteration or error handling when operating on potentially non-existent elements.

Highlights

  • New API Methods: Implemented hasNode, hasEdge, and hasCombo methods in the Graph class to check for the existence of graph elements by their ID.
  • Test Coverage: Added comprehensive unit tests for the newly introduced hasNode, hasEdge, and hasCombo APIs, covering various scenarios including valid and invalid IDs.
  • Documentation: Updated the API documentation in both English and Chinese to include details and usage examples for the hasNode, hasEdge, and hasCombo methods.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces hasNode, hasEdge, and hasCombo APIs to the graph instance, allowing for easy existence checks of graph elements. The implementation in graph.ts and the corresponding tests in graph.spec.ts are well-done. My feedback focuses on improving the documentation for these new APIs to ensure clarity and consistency across different languages.

Comment on lines +809 to +875
### Graph.hasNode()

Determine if an node exists

```typescript
hasNode(id:ID): boolean;
```

**参数**:
| Parameter | Description | Type | Default | Required |
| ---- | -------------------- | --------- | ------ | ---- |
| id | Node ID to be judged | [ID](#id) | - | ✓ |

**返回值**:

- **类型**: boolean
**示例**:

```typescript
graph.hasNode('node-1');
```

### Graph.hasEdge()

Determine if an edge exists

```typescript
hasEdge(id:ID): boolean;
```

**参数**:

| Parameter | Description | Type | Default | Required |
| --------- | -------------------- | --------- | ------- | -------- |
| id | Edge ID to be judged | [ID](#id) | - | ✓ |

**返回值**:

- **类型**: boolean
**示例**:

```typescript
graph.hasEdge('edge-1');
```

### Graph.hasCombo()

Determine if combo exists

```typescript
hasCombo(id:ID): boolean;
```

**参数**:

| Parameter | Description | Type | Default | Required |
| --------- | --------------------- | --------- | ------- | -------- |
| id | Combo ID to be judged | [ID](#id) | - | ✓ |

**返回值**:

- **类型**: boolean
**示例**:

```typescript
graph.hasCombo('combo-1');
```
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The documentation for the new hasNode, hasEdge, and hasCombo APIs in the English documentation file contains some inconsistencies and localization issues.

  • There are grammatical errors in the descriptions (e.g., "an node" instead of "a node").
  • Section headers like 参数 (Parameters) and 返回值 (Return Value) are in Chinese. They should be translated to English for this file.
  • The markdown table for hasNode is misaligned.

I've provided a suggestion to fix these issues for better readability and consistency.

### Graph.hasNode()

Determine if a node exists

```typescript
hasNode(id:ID): boolean;

Parameters:

Parameter Description Type Default Required
id Node ID to be judged ID -

Return Value:

  • Type: boolean

Example:

graph.hasNode('node-1');

Graph.hasEdge()

Determine if an edge exists

hasEdge(id:ID): boolean;

Parameters:

Parameter Description Type Default Required
id Edge ID to be judged ID -

Return Value:

  • Type: boolean

Example:

graph.hasEdge('edge-1');

Graph.hasCombo()

Determine if a combo exists

hasCombo(id:ID): boolean;

Parameters:

Parameter Description Type Default Required
id Combo ID to be judged ID -

Return Value:

  • Type: boolean

Example:

graph.hasCombo('combo-1');

Comment on lines +809 to +876
### Graph.hasNode()

判断节点是否存在

```typescript
hasNode(id:ID): boolean;
```

**参数**:

| 参数 | 描述 | 类型 | 默认值 | 必选 |
| ---- | -------------------- | --------- | ------ | ---- |
| id | 需要进行判断的节点id | [ID](#id) | - | ✓ |

**返回值**:

- **类型**: boolean
**示例**:

```typescript
graph.hasNode('node-1');
```

### Graph.hasEdge()

判断边是否存在

```typescript
hasEdge(id:ID): boolean;
```

**参数**:

| 参数 | 描述 | 类型 | 默认值 | 必选 |
| ---- | ------------------ | --------- | ------ | ---- |
| id | 需要进行判断的边id | [ID](#id) | - | ✓ |

**返回值**:

- **类型**: boolean
**示例**:

```typescript
graph.hasEdge('edge-1');
```

### Graph.hasCombo()

判断combo是否存在

```typescript
hasCombo(id:ID): boolean;
```

**参数**:

| 参数 | 描述 | 类型 | 默认值 | 必选 |
| ---- | ------------------------- | --------- | ------ | ---- |
| id | 需要进行判断的combo组合id | [ID](#id) | - | ✓ |

**返回值**:

- **类型**: boolean
**示例**:

```typescript
graph.hasCombo('combo-1');
```
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The Chinese documentation for the new APIs has some inconsistencies.

  • The term "combo" is used instead of its Chinese equivalent "组合".
  • The descriptions for element IDs use lowercase "id" instead of "ID" for consistency.

I've provided a suggestion to correct these to improve the documentation's clarity and consistency.

### Graph.hasNode()

判断节点是否存在

```typescript
hasNode(id:ID): boolean;

参数:

参数 描述 类型 默认值 必选
id 需要进行判断的节点 ID ID -

返回值:

  • 类型: boolean

示例:

graph.hasNode('node-1');

Graph.hasEdge()

判断边是否存在

hasEdge(id:ID): boolean;

参数:

参数 描述 类型 默认值 必选
id 需要进行判断的边 ID ID -

返回值:

  • 类型: boolean

示例:

graph.hasEdge('edge-1');

Graph.hasCombo()

判断组合是否存在

hasCombo(id:ID): boolean;

参数:

参数 描述 类型 默认值 必选
id 需要进行判断的组合 ID ID -

返回值:

  • 类型: boolean

示例:

graph.hasCombo('combo-1');

@Aarebecca Aarebecca merged commit 79b41a3 into v5 Aug 18, 2025
3 checks passed
@Aarebecca Aarebecca deleted the feat/rubbishmaker-expand-graph-methods-20250802 branch August 18, 2025 13:10
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.

3 participants