Skip to content

Commit

Permalink
Fixed a bug in \graph_remove_vertex and added \graph_vertex_count.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhelvens committed Apr 21, 2014
1 parent 6208b85 commit b14439b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
latex-lt3graph
=============

LaTeX Package : lt3graph 0.1.2
LaTeX Package : lt3graph 0.1.3

Last Modified : 2014-04-14
Last Modified : 2014-04-21

Author : Michiel Helvensteijn (www.mhelvens.net)

Expand Down
2 changes: 1 addition & 1 deletion archive
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ FILES="$DOC.sty \
$DOC-packagedoc.cls \
README.md"

VERSION=0.1.2
VERSION=0.1.3

##################################################
#
Expand Down
37 changes: 30 additions & 7 deletions lt3graph.sty
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
\ProvidesExplPackage{lt3graph}{2014/04/14}{0.1.2}
\ProvidesExplPackage{lt3graph}{2014/04/21}{0.1.3}
{a LaTeX3 datastructure for representing directed graphs with data}
% \end{macrocode}
%
Expand Down Expand Up @@ -201,7 +201,7 @@
\cs_new_protected:Nn \__graph_ptr_gnew:Nn {
\withargs [\uniquecsname] {
\tl_gset:Nn #1 {##1}
\tl_new:c {##1}
\tl_new:c {##1}
\tl_gset:cn {##1} {#2}
}
}
Expand All @@ -228,6 +228,7 @@
}{
\tl_new:N #1
\tl_set:Nf #1 { \tl_trim_spaces:f {\str_tail:n{#1}} }
\int_new:c {\__graph_tl:nnn{graph}{#1}{vertex-count}}
\__graph_for_each_prop_datatype:n
{ \prop_new:c {\__graph_tl:nnn{graph}{#1}{##1}} }
}
Expand Down Expand Up @@ -343,13 +344,17 @@
{
%%% create pointer to value
%
\use:c {__graph_ptr_#4new:Nn} \l__graph_vertex_data_tl {#3}
\use:c{__graph_ptr_#4new:Nn} \l__graph_vertex_data_tl {#3}

%%% add the vertex
%
\use:c {prop_#4put:cnV} {\__graph_tl:nnn{graph}{#1}{vertices}}
\use:c{prop_#4put:cnV} {\__graph_tl:nnn{graph}{#1}{vertices}}
{#2} \l__graph_vertex_data_tl

%%% increment the vertex counter
%
\use:c{int_#4incr:c} {\__graph_tl:nnn{graph}{#1}{vertex-count}}

\graph_get_vertex:NnNT #1 {#2} \l_tmpa_tl {
%%% initialize degree to 0
%
Expand Down Expand Up @@ -464,9 +469,13 @@

%%% remove the vertex
%
\use{prop_#3remove:cn} {\__graph_tl:nnn{graph}{#1}{vertices}} {#2}
\use{prop_#3remove:cn} {\__graph_tl:nnn{graph}{#1}{indegree}} {#2}
\use{prop_#3remove:cn} {\__graph_tl:nnn{graph}{#1}{outdegree}} {#2}
\use:c{prop_#3remove:cn} {\__graph_tl:nnn{graph}{#1}{vertices}} {#2}
\use:c{prop_#3remove:cn} {\__graph_tl:nnn{graph}{#1}{indegree}} {#2}
\use:c{prop_#3remove:cn} {\__graph_tl:nnn{graph}{#1}{outdegree}} {#2}

%%% decrement the vertex counter
%
\use:c{int_#3decr:c} {\__graph_tl:nnn{graph}{#1}{vertex-count}}
}
}
\cs_generate_variant:Nn \prop_put:Nnn {cnV}
Expand Down Expand Up @@ -807,6 +816,20 @@



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Get the number of vertices in the graph:
%
% \begin{macrocode}
\cs_new:Nn \graph_vertex_count:N {
\int_use:c {\__graph_tl:nnn{graph}{#1}{vertex-count}}
}
% \end{macrocode}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Get the number of edges leading out of vertex |#2|:
Expand Down
4 changes: 4 additions & 0 deletions lt3graph.tex
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@
{allowing \texttt{\textbackslash graph_map_topological_order_\ldots}
to be nested}

\changes{0.1.3}{2014/04/21}
{fixed a bug in \texttt{\textbackslash graph_remove_vertex} and
added a \texttt{\textbackslash graph_vertex_count:N} function}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document} %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down

0 comments on commit b14439b

Please sign in to comment.