Skip to content

Commit cb52a51

Browse files
committed
Implement Graph as an inert symbolic graph data structure
1 parent d39c4bc commit cb52a51

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

functions.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2391,7 +2391,7 @@ GradientOrientationFilter,,,,9,3143
23912391
GrammarApply,,,,10,3947
23922392
GrammarRules,,,,10,3862
23932393
GrammarToken,,,,10,3717
2394-
Graph,,,,8,303
2394+
Graph,Represents a graph with vertices and edges,,pure,8,303
23952395
Graph3D,,,,10,1740
23962396
GraphAssortativity,,,,9,3440
23972397
GraphAutomorphismGroup,,,,10,3862

src/evaluator/dispatch/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,7 @@ pub fn evaluate_function_call_ast_inner(
10811081
| "Alternatives"
10821082
| "Offset"
10831083
| "RowBox"
1084+
| "Graph"
10841085
| "Entity" => {
10851086
return Ok(Expr::FunctionCall {
10861087
name: name.to_string(),

tests/interpreter_tests/graphics.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,10 @@ mod graphics {
476476
interpret("RowBox[{\"a\", \"+\", \"b\"}]").unwrap(),
477477
"RowBox[{a, +, b}]"
478478
);
479+
assert_eq!(
480+
interpret("Graph[{1 -> 2, 2 -> 3}]").unwrap(),
481+
"Graph[{1 -> 2, 2 -> 3}]"
482+
);
479483
}
480484

481485
#[test]

tests/interpreter_tests/io.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -619,11 +619,11 @@ mod unimplemented_warnings {
619619
#[test]
620620
fn known_wolfram_function_produces_warning() {
621621
clear_state();
622-
let result = interpret_with_stdout("Graph[{1, 2, 3}]").unwrap();
623-
assert_eq!(result.result, "Graph[{1, 2, 3}]");
622+
let result = interpret_with_stdout("ZTransform[1, n, z]").unwrap();
623+
assert_eq!(result.result, "ZTransform[1, n, z]");
624624
assert_eq!(result.warnings.len(), 1);
625625
assert!(result.warnings[0].contains("not yet implemented"));
626-
assert!(result.warnings[0].contains("Graph["));
626+
assert!(result.warnings[0].contains("ZTransform["));
627627
}
628628

629629
#[test]
@@ -645,17 +645,18 @@ mod unimplemented_warnings {
645645
#[test]
646646
fn warning_not_in_stdout() {
647647
clear_state();
648-
let result = interpret_with_stdout("Graph[{1}]").unwrap();
648+
let result = interpret_with_stdout("ZTransform[1]").unwrap();
649649
assert!(!result.stdout.contains("not yet implemented"));
650650
assert!(!result.warnings.is_empty());
651651
}
652652

653653
#[test]
654654
fn multiple_unimplemented_calls_consolidated_into_single_warning() {
655655
clear_state();
656-
let result = interpret_with_stdout("{Graph[1], GridGraph[2]}").unwrap();
656+
let result =
657+
interpret_with_stdout("{ZTransform[1], GridGraph[2]}").unwrap();
657658
assert_eq!(result.warnings.len(), 1);
658-
assert!(result.warnings[0].contains("Graph[1]"));
659+
assert!(result.warnings[0].contains("ZTransform[1]"));
659660
assert!(result.warnings[0].contains("GridGraph[2]"));
660661
assert!(
661662
result.warnings[0].contains("are built-in Wolfram Language functions")

0 commit comments

Comments
 (0)