Skip to content

Commit 06016c4

Browse files
committed
Merge branch 'fe-edge' into fe-rag
2 parents 00eb141 + 0fa760e commit 06016c4

File tree

3 files changed

+56
-18
lines changed

3 files changed

+56
-18
lines changed

backend/app/main.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,13 +518,15 @@ def create_edges_on_graph():
518518
"common_stargazers_enabled": true,
519519
"stargazer_threshold": 5,
520520
"use_and_logic": false
521-
}
521+
},
522+
"filtered_node_ids": ["node1", "node2", ...] // Optional: only consider these nodes for edge creation
522523
}
523524
"""
524525
try:
525526
data = request.get_json()
526527
gexf_content = data.get("gexfContent", "")
527528
criteria_config = data.get("criteria_config", {})
529+
filtered_node_ids = data.get("filtered_node_ids", None) # Get filtered node IDs
528530

529531
if not gexf_content:
530532
return jsonify({
@@ -574,7 +576,7 @@ def create_edges_on_graph():
574576
edge_service = EdgeGenerationService()
575577

576578
# Create edges based on the criteria
577-
edges_created = edge_service.create_edges_on_existing_graph(G, criteria_config)
579+
edges_created = edge_service.create_edges_on_existing_graph(G, criteria_config, filtered_node_ids)
578580

579581
# Save the updated graph
580582
import hashlib

backend/app/services/edge_generation_service.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,14 @@ def generate_edges_with_criteria(
116116

117117
return G, edge_stats
118118

119-
def create_edges_on_existing_graph(self, G: nx.Graph, criteria_config: Dict[str, any]) -> Dict[str, any]:
119+
def create_edges_on_existing_graph(self, G: nx.Graph, criteria_config: Dict[str, any], filtered_node_ids: List[str] = None) -> Dict[str, any]:
120120
"""
121121
Create edges on an existing graph based on specified criteria.
122122
123123
Args:
124124
G: Existing NetworkX graph with nodes
125125
criteria_config: Configuration for edge generation criteria
126+
filtered_node_ids: Optional list of node IDs to consider for edge creation (only these nodes will be used)
126127
127128
Returns:
128129
Dictionary with statistics about created edges
@@ -152,10 +153,27 @@ def create_edges_on_existing_graph(self, G: nx.Graph, criteria_config: Dict[str,
152153
# Remove all existing edges first
153154
G.remove_edges_from(list(G.edges()))
154155

155-
# Get all nodes
156-
nodes = list(G.nodes())
157-
if len(nodes) < 2:
158-
return {'message': 'Not enough nodes to create edges'}
156+
# Use filtered nodes if provided, otherwise use all nodes
157+
if filtered_node_ids is not None:
158+
# Validate that all filtered node IDs exist in the graph
159+
existing_nodes = set(G.nodes())
160+
valid_filtered_nodes = [node_id for node_id in filtered_node_ids if node_id in existing_nodes]
161+
162+
if len(valid_filtered_nodes) < 2:
163+
return {
164+
'message': f'Not enough valid filtered nodes to create edges. Found {len(valid_filtered_nodes)} valid nodes out of {len(filtered_node_ids)} provided.',
165+
'total_edges': 0,
166+
'total_nodes': len(valid_filtered_nodes)
167+
}
168+
169+
nodes = valid_filtered_nodes
170+
print(f"Using {len(nodes)} filtered nodes for edge creation out of {len(existing_nodes)} total nodes")
171+
else:
172+
# Use all nodes if no filtering is applied
173+
nodes = list(G.nodes())
174+
if len(nodes) < 2:
175+
return {'message': 'Not enough nodes to create edges'}
176+
print(f"Using all {len(nodes)} nodes for edge creation")
159177

160178
# Generate edges based on enabled criteria
161179
edge_stats = {}

src/views/EdgePanel.tsx

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,19 @@ const EdgePanel: FC<{ isExpanded: boolean }> = ({ isExpanded }) => {
213213
use_and_logic: enabledCriteria > 1 // Use AND logic if multiple criteria enabled
214214
};
215215

216-
// Call backend API with original graph
216+
// Get filtered node IDs to pass to backend
217+
const filteredNodeIds = computedData?.filteredNodes ? Array.from(computedData.filteredNodes) : null;
218+
219+
// Call backend API with original graph and filtered nodes
217220
const response = await fetch('http://127.0.0.1:5002/api/create-edges-on-graph', {
218221
method: 'POST',
219222
headers: {
220223
'Content-Type': 'application/json',
221224
},
222225
body: JSON.stringify({
223226
gexfContent: originalGexfContent,
224-
criteria_config: criteriaConfig
227+
criteria_config: criteriaConfig,
228+
filtered_node_ids: filteredNodeIds
225229
})
226230
});
227231

@@ -315,8 +319,18 @@ const EdgePanel: FC<{ isExpanded: boolean }> = ({ isExpanded }) => {
315319

316320
// Notify user of success
317321
const edgesCreated = result.edgesCreated?.total_edges || 0;
322+
const nodeCount = computedData?.filteredNodes ? computedData.filteredNodes.size : data?.graph?.order || 0;
323+
const totalNodes = data?.graph?.order || 0;
324+
325+
let successMessage = `Successfully created ${edgesCreated} edges`;
326+
if (computedData?.filteredNodes && computedData.filteredNodes.size < totalNodes) {
327+
successMessage += ` using ${nodeCount} filtered nodes (out of ${totalNodes} total)`;
328+
} else {
329+
successMessage += ` from original graph`;
330+
}
331+
318332
notify({
319-
message: `Successfully created ${edgesCreated} edges from original graph`,
333+
message: successMessage,
320334
type: "success"
321335
});
322336

@@ -399,7 +413,18 @@ const EdgePanel: FC<{ isExpanded: boolean }> = ({ isExpanded }) => {
399413
</h1>
400414

401415
<div className="mb-3">
402-
<h3 className="form-label fs-6 mb-3">Configure how edges are automatically created between repositories based on various criteria</h3>
416+
<h3 className="form-label fs-6 mb-3">
417+
Configure how edges are automatically created between repositories based on various criteria
418+
{computedData?.filteredNodes && (
419+
<>
420+
<br />
421+
<br />
422+
<span className="text-white">
423+
Note: Edge creation will only consider currently visible nodes. Hidden/filtered nodes will not participate in edge creation.
424+
</span>
425+
</>
426+
)}
427+
</h3>
403428
</div>
404429

405430
{/* Topic Based Linking */}
@@ -549,13 +574,6 @@ const EdgePanel: FC<{ isExpanded: boolean }> = ({ isExpanded }) => {
549574

550575
{/* Apply Button */}
551576
<div className="mb-3">
552-
{computedData?.filteredNodes && (
553-
<div className="alert alert-info small mb-3">
554-
<strong>Note:</strong> Edge creation will only consider currently visible nodes ({computedData.filteredNodes.size} of {data?.graph?.order || 0} total).
555-
Hidden/filtered nodes will not participate in edge creation.
556-
</div>
557-
)}
558-
559577
{/* Warning when no criteria are selected */}
560578
{!enableTopicLinking && !enableSharedOrganization && !enableContributorOverlap && !enableCommonStargazers && (
561579
<div className="alert alert-info small mb-3">

0 commit comments

Comments
 (0)