Changelog
0.14.0 - Unreleased
Reworks how named vertices and edges are translated to the integer vertices and edges used internally.
Breaking changes
- The
NamedGraphGenerators,GraphsExtensions,GraphGenerators, andSimilarTypesubmodules are removed and their contents moved intoNamedGraphs, sousing NamedGraphs.GraphsExtensions: boundary_edgesbecomesusing NamedGraphs: boundary_edges,using NamedGraphs.NamedGraphGenerators: named_gridbecomesusing NamedGraphs: named_grid, and so on (#183, #187, #189, #190). edges(g)outputs a lazy iterator instead of aVector, likeedges(::SimpleGraph)in Graphs.jl. Membership (in) matcheshas_edge, and==between two edge iterators compares the edge sets. Code that indexed,filtered, orfindfirsted the result shouldcollectit first, andvcattakes the iterator as a single element rather than a collection, so it silently returns a nestedVector{Any}where it previously combined the edges. Iteration,length,first,issetequal,union,setdiff, broadcasting, and building aDictionaryorIndicesall work directly. The output is a live view of the graph rather than a snapshot, so holding on to it across a mutation of the graph now sees the mutation (#178).vertices(g::Named[Di]Graph)outputs aDictionaries.Indicesinstead of the internalOrderedIndicestype, and theOrderedDictionariesandOrdinalIndexingsubmodules are removed along with their contents. OtherAbstractNamedGraphtypes can output otherAbstractIndicesset views. Indexing is by vertex name, not position, andvertices(g)[4th]becomesdecoded_vertex(g, 4)(#178).- Vertices iterate in insertion order, which no longer matches the integer codes after a removal, where v0.13 kept the two in agreement. Nothing errors, so code that maps a result computed on the integer graph back through
collect(vertices(g))[code]silently gets the wrong vertex. Translate withdecoded_vertex(g, code)instead (#178). - The "position graph" terminology is replaced with encode and decode terminology. The overloads for implementing a new
AbstractNamedGraphareencoded_graph(g)(replacesposition_graph, with a genericEncodedGraphViewfallback so a graph type does not need to store an integer graph),encoded_vertex(g, v)(replacesvertex_positions), anddecoded_vertex(g, c)(replacesordered_vertices). Codes are not stable across mutation. The last two translate a single vertex where the functions they replace returned a whole mapping, so a type that forwarded all three in a loop over function names has to write them out separately (#178). rem_vertex!,add_edge!, andrem_edge!returntrueorfalsefollowing Graphs.jl, matchingadd_vertex!. Previously they returned the graph, andadd_edge!/rem_edge!threw for edges with vertices not in the graph, which now returnsfalse. A type defining these needs ahas_vertexguard so that removing an absent vertex returnsfalseinstead of throwing, andDictionaries.unset!in place ofdelete!(#179).- The plural mutators
add_edges!,rem_edges!,add_vertices!, andrem_vertices!return the number of successful additions or removals, where they previously returned the graph.Boolfrom the singularGraphs.add_edge!is the one-element case of the same count, andGraphs.add_vertices!already returned a count.rem_quotientvertex!andrem_quotientedge!likewise return how many underlying vertices or edges went, so0means the quotient vertex or edge was not there (#188). add_vertices!andrem_vertices!are methods of the Graphs.jl functions of those names rather than separate functions of NamedGraphs' own, and are declared onAbstractNamedGraph. An integer second argument is a vertex name here, not upstream's count of vertices to append, since a named graph cannot invent names (#188).- Considerably more names are exported, where previously only the four graph and edge types were, so
using NamedGraphscan collide with names another package exports (#188). - The
Keyssubmodule and itsKeytype are removed with no replacement. Code that usedKeyneeds its own equivalent (#183). all_edgestakes anAbstractNamedGraph, where it previously took anyGraphs.AbstractGraph, and outputs a lazy iterator, so on a directed graph it no longer returns an allocatedVector(#192).GenericNamedGraph{V, G}is removed (it was not exported, so this only affects code that imported it explicitly).NamedGraph{V}andNamedDiGraph{V}are now separately defined concrete types, hardcoded toSimpleGraph{Int}andSimpleDiGraph{Int}underlying storage (#179).- The wrappers around Graphs.jl functions mirror the upstream positional signatures instead of taking
args...or untyped arguments, so some argument types that were previously accepted no longer are. In particular,eccentricity(graph, x)is always the eccentricity of the single vertexx, witheccentricitiesas the every-vertex form, and aVector{Bool}passed toinduced_subgraphis a list of vertex names rather than a mask over1:nv(graph).induced_subgraphalso throws for vertices the graph does not have, where it previously returned a graph built on them (#186). rename_vertices(edge, name_map)is removed. Writerename_vertices(v -> name_map[v], edge)(#184).- The internal helpers behind the Graphs.jl wrappers are renamed from
namedgraph_ftof_namedgraph, matching the suffix convention already used bysimilar_namedgraphand others.AbstractNamedGraphsubtypes should now override these hooks rather than the Graphs.jl functions themselves, which means a subtype no longer needs its own::Integerdisambiguator (#187).
Non-breaking changes
- Basic operations on a graph whose vertices happen to be integers work again.
common_neighbors(g, 1, 3),has_path(g, 1, 3),eccentricity(g, 1),dijkstra_shortest_paths(g, 1)and others were ambiguous with the Graphs.jl methods and raised aMethodError(#186, #187). Indexing aQuotientViewby a collection of vertices or edges was broken the same way and also works now. all_edgesis documented and exported (#192).Combinatorics,Random,Suppressor,SimpleGraphConverter, andPackageExtensionCompatare no longer dependencies, so installing NamedGraphs no longer pulls inOptimorLightXML(#185, #188).- The docs are reorganized into user and developer interface pages, the graph types and generators are documented, and the README has an introduction and examples (#183).
NamedGraphs.PartitionedGraphsdocuments and exports its user-facing API, sousing NamedGraphs.PartitionedGraphsbrings the partitioned graph types and the quotient vertex and edge functions into scope where it previously brought nothing (#188).bfs_parents(g, v)anddfs_parents(g, v)map vertices unreachable fromvto themselves, likedijkstra_shortest_pathsdoes. Previously they errored on graphs with unreachable vertices (#179).